home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol434 / xwindow.arc / MANUAL.DOC
Encoding:
Text File  |  1987-12-18  |  761.0 KB  |  27,239 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                Xlib - C Language X Interface
  17.  
  18.                     Protocol Version 11
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                          Jim Gettys
  26.                Digital Equipment Corporation
  27.                   Systems Research Center
  28.                      MIT Project Athena
  29.  
  30.  
  31.                          Ron Newman
  32.            Massachusetts Institute of Technology
  33.                      MIT Project Athena
  34.  
  35.  
  36.                     Robert W. Scheifler
  37.            Massachusetts Institute of Technology
  38.               Laboratory for Computer Science
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                      December 18, 1987
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                            - 2 -
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. The X Window System is a trademark of MIT.
  82.  
  83. ULTRIX, ULTRIX-32, ULTRIX-32m, ULTRIX-32w, and VAX/VMS are
  84. trademarks of Digital Equipment Corporation.
  85.  
  86. UNIX is a trademark of AT&T Bell Laboratories.
  87.  
  88. Copyright c 1985, 1986, 1987, Massachusetts Institute of
  89. Technology, Cambridge, Massachusetts, and Digital Equipment
  90. Corporation, Maynard, Massachusetts.
  91.  
  92. Permission to use, copy, modify and distribute this documen-
  93. tation for any purpose and without fee is hereby granted,
  94. provided that the above copyright notice appears in all
  95. copies and that both that copyright notice and this permis-
  96. sion notice appear in supporting documentation, and that the
  97. name of M.I.T. or Digital not be used in in advertising or
  98. publicity pertaining to distribution of the software without
  99. specific, written prior permission.  M.I.T and Digital makes
  100. no representations about the suitability of the software
  101. described herein for any purpose.  It is provided ``as is''
  102. without express or implied warranty.
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                      December 18, 1987
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                            - 3 -
  135.  
  136.  
  137. Table of Contents Preface
  138.  
  139.                           Preface
  140.  
  141.  
  142.  
  143. Whereas the design and implementation of the first 10 ver-
  144. sions of X were primarily the work of three individuals,
  145. Robert Scheifler of the MIT  Laboratory for Computer Science
  146. and Jim Gettys of Digital Equipment Corporation and Ron New-
  147. man of MIT, both at MIT Project Athena, X version 11 is the
  148. result of the efforts of literally dozens of individuals at
  149. almost as many locations and organizations.  At the risk of
  150. offending some of the players by exclusion, many people
  151. deserve special credit and recognition.  Our apologies to
  152. anyone inadvertently overlooked.
  153.  
  154. First, Phil Karlton and Scott McGregor, both of Digital, for
  155. their considerable contributions to the specification of the
  156. version 11 protocol.  Sue Angebranndt, Raymond Drewry, Todd
  157. Newman and Phil Karlton of Digital have worked long and hard
  158. to produce the sample server implementation.
  159.  
  160. Todd Brunhoff of Tektronix was ``loaned'' to Project Athena
  161. at exactly the right moment to provide very capable and much
  162. needed assistance during the alpha and beta releases.  He is
  163. totally responsible for the successfull integration of
  164. sources from multiple sites; we simply wouldn't have a
  165. release without him.
  166.  
  167. Ralph Swick of Project Athena and Digital kept it all
  168. together for us.  He has handled literally thousands of
  169. requests for people everywhere and saved the sanity of one
  170. of us (JG).  His calm good cheer has been a foundation on
  171. which we could build.
  172.  
  173. Special thanks must also go to Sam Fuller, Vice President of
  174. Corporate Research at Digital, who has remained committed to
  175. the widest public availability of X and who made it possible
  176. to greatly supplement MIT's resources with the Digital staff
  177. in order to make version 11 a reality.  Many of the people
  178. mentioned here are part of the Western Software Laboratory
  179. (Digital UEG-WSL) of the ULTRIX Engineering group, who work
  180. for Smokey Wallace, who has been vital to the project's suc-
  181. cess; additional others have worked on the toolkit, and are
  182. acknowledged there.
  183.  
  184. Our thanks also go to Al Mento and Al Wojtas of Digital's
  185. ULTRIX Documentation Group.  With good humor and cheer, they
  186. took a rough draft of the V11 Xlib manual and made it an
  187. infinitely better and more useful document.  The work they
  188. have done will help many everywhere.  We also would like to
  189. thank Hal Murray (Digital SRC) and Peter George (Digital
  190. VMS) who contributed much by proof reading this manual.
  191.  
  192.  
  193.  
  194.                      December 18, 1987
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                            - 4 -
  201.  
  202.  
  203. We would like to thank Jeff Dike (Digital UEG), Tom Benson,
  204. Jackie Granfield, and Vince Orgovan (Digital VMS) who helped
  205. with the library utilities implementation.
  206.  
  207. Hania Gajewska (Digital UEG-WSL) was instrumental in the
  208. semantic design of the window manager properties along with
  209. Ellis Cohen of CMU and Siemens.
  210.  
  211. Dave Rosenthal of Sun Microsystems also contributed to the
  212. protocol and provided the sample generic color frame buffer
  213. device dependent code.
  214.  
  215. The alpha and beta test participants deserve recognition as
  216. well.  It is significant that the bug reports (and many
  217. fixes) during alpha and beta test came almost exclusively
  218. from just a few of the alpha testers, mostly hardware ven-
  219. dors working on product implementations of X. The continued
  220. public contribution of vendors and universities is certainly
  221. to the benefit of the entire X community.
  222.  
  223. The Version 11 protocol was authored by Bob Scheifler of
  224. MIT's Laboratory for computer science.  Contributers to the
  225. design were:
  226.  
  227.  
  228.         Dave Carver (Digital HPW)
  229.         Branko Gerovac (Digital HPW)
  230.         Jim Gettys (MIT/Project Athena, Digital)
  231.         Phil Karlton (Digital WSL)
  232.         Scott McGregor (Digital SSG)
  233.         Ram Rao (Digital UEG)
  234.         David Rosenthal (Sun)
  235.         Dave Winchell (Digital UEG)
  236.  
  237.  
  238. Invited reviewers who provided useful input:
  239.  
  240.         Andrew Cherenson (Berkeley)
  241.         Burns Fisher (Digital)
  242.         Dan Garfinkel (HP)
  243.         Leo Hourvitz (Next)
  244.         Brock Krizan (HP)
  245.         David Laidlaw (Stellar)
  246.         Dave Mellinger (Interleaf)
  247.         Ron Newman (MIT)
  248.         John Ousterhout (Berkeley)
  249.         Andrew Palay (ITC CMU)
  250.         Ralph Swick (MIT/Project Athena, Digital)
  251.         Craig Taylor (Sun)
  252.         Jeffery Vroom (Stellar)
  253.  
  254. And of course, we must acknowledge Paul Asente, of Stanford
  255. University, who wrote W, the predecessor to X.
  256.  
  257.  
  258.  
  259.  
  260.                      December 18, 1987
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                            - 5 -
  267.  
  268.  
  269. And thanks must also go to MIT,  Digital Equipment Corpora-
  270. tion, and IBM for providing the environment where it could
  271. happen.
  272.  
  273.  
  274. Jim Gettys
  275. Systems Research Center
  276. MIT / Project Athena
  277. Digital Equipment Corporation
  278.  
  279. Ron Newman
  280. Project Athena
  281. Massachusetts Institute of Technology
  282.  
  283. Robert W. Scheifler
  284. Laboratory for Computer Science
  285. Massachusetts Institute of Technology
  286.  
  287. September 15, 1987
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.                      December 18, 1987
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.                          Chapter 1
  338.  
  339.                     Introduction to Xlib
  340.  
  341.  
  342.  
  343. Introduction to Xlib The X Window System is a network tran-
  344. sparent windowing system that was designed at MIT and that
  345. runs under 4.3BSD UNIX, ULTRIX-32, many other UNIX variants,
  346. VAX/VMS, as well as several other operating systems.
  347.  
  348. X display servers run on computers with either monochrome or
  349. color bitmap terminals.  The server distributes user input
  350. to and accepts output requests from various client programs
  351. located either on the same machine or elsewhere in your net-
  352. work.  Xlib is a C subroutine library that application pro-
  353. grams (clients) use to interface with the window system by
  354. means of a stream connection.  Although a client usually
  355. runs on the same machine as the X server it is talking to,
  356. this need not be the case.
  357.  
  358. This manual is a descriptive guide to the low-level C
  359. language interface to the X Window System protocol.  It is
  360. neither a tutorial nor a user guide to programming to the X
  361. Window System.  Other high-level abstractions (for example,
  362. those provided by the toolkits for X) are built on top of
  363. the Xlib library.  For further information about these
  364. high-level libraries, see the appropriate toolkit documenta-
  365. tion.  For general information about the design of X, see
  366. ``The X Window System.''
  367.  
  368. This manual assumes a basic understanding of a graphics win-
  369. dow system and of the C programming language.  To provide an
  370. introduction to X programming, this chapter discusses:
  371.  
  372. o    Overview of the X Window System
  373.  
  374. o    Naming and argument conventions
  375.  
  376. o    Programming considerations
  377.  
  378. 1.1.  Overview of the X Window System
  379.  
  380. Some of the terms used in this book are unique to X, while
  381. other terms that are common to other window systems have
  382. different meanings in X.  You may find it helpful to refer
  383. to the glossary, located at the end of the book, when you
  384. are uncertain of a term's meaning in the context of the X
  385. Window System.
  386.  
  387. The X Window System supports one or more screens containing
  388. overlapping windows or subwindows.  A screen is a physical
  389.  
  390.  
  391.  
  392.                      December 18, 1987
  393.  
  394.  
  395.  
  396.  
  397.  
  398.                            - 2 -
  399.  
  400.  
  401. monitor and hardware, which may be either color or black and
  402. white.  There can be multiple screens per display or works-
  403. tation.
  404.  
  405. All the windows in an X server are arranged in a strict
  406. hierarchy.  At the top of the hierarchy are the root win-
  407. dows, which cover each of the display screens.  Each root
  408. window is partially or completely covered by child windows.
  409. All windows, except for root windows, have parents.  There
  410. is usually at least one window per application program.
  411. Child windows  may in turn have their own children.  In this
  412. way, an application program can create a tree of arbitrary
  413. depth on each screen.
  414.  
  415. A child window may be larger than its parent. That is, part
  416. or all of the child window may extend beyond the boundaries
  417. of the parent.  However, all output to a window is clipped
  418. by the boundaries of its parent window.  If several children
  419. of a window have overlapping locations, one of the children
  420. is considered to be on top of or raised over the others,
  421. obscuring them.  Output to areas covered by other windows
  422. will be suppressed by the window system.  If a window  is
  423. obscured by a second window, the window will obscure only
  424. those ancestors of the second window, which are also ances-
  425. tors of the first window.
  426.  
  427. A window has a border of zero or more pixels in width, which
  428. can be any pattern (pixmap) or solid color you like.  A win-
  429. dow usually but not always has a background pattern which
  430. will be repainted by the window system when uncovered.  Each
  431. window has its own coordinate system.  Child windows obscure
  432. their parents unless the child windows have no b ackground,
  433. and graphic operations in the parent window usually are
  434. clipped by the children.
  435.  
  436. Input from X takes the form of events.  Events may either be
  437. side effects of a command (for example, restacking windows
  438. generates exposure events) or completely asynchronous (for
  439. example, the keyboard).  A client program asks to be
  440. informed of events.  X never sends events a program did not
  441. ask for.
  442.  
  443. X does not take responsibility for the contents of windows.
  444. When part or all of a window is hidden and then brought back
  445. onto the screen, its contents may be lost, and the client
  446. program is notified (by an exposure event) that part or all
  447. of the window needs to be repainted.  Programs must be
  448. prepared to regenerate the contents of windows on demand.
  449.  
  450. X also provides off screen storage of graphics objects,
  451. called ``pixmaps.''  Single plane (depth 1) pixmaps are
  452. sometimes referred to as ``bitmaps.''  These can be used in
  453. most graphics functions interchangably with windows, and are
  454. used in various graphics operations to define patterns also
  455.  
  456.  
  457.  
  458.                      December 18, 1987
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                            - 3 -
  465.  
  466.  
  467. called ``tiles.''  Windows and pixmaps together are referred
  468. to as ``drawables.''
  469.  
  470. Most of the functions in Xlib just add requests to an output
  471. buffer.  These requests later execute asynchronously on the
  472. X server, often referred to as display server.  Functions
  473. that return values of information stored in the server do
  474. not return (that is, they ``block'') until an explicit reply
  475. is received or an error occurs.  If a nonblocking  call
  476. results in an error, the error will generally not be
  477. reported by a call to an optional error handler until some
  478. later, blocking call is made.
  479.  
  480. If it does not want a request to execute asynchronously, a
  481. client can follow it with a call to XSync, which will block
  482. until all previously buffered asynchronous events have been
  483. sent and acted on.  As an important side effect, the output
  484. buffer is always flushed by a call to any function which
  485. returns a value or waits for input (for example, XPending,
  486. XNextEvent, XWindowEvent, XFlush, or XSync).
  487.  
  488. Many Xlib functions will return an integer resource ID,
  489. which allows you to refer to objects stored on the X server.
  490. These can be of type Window, Font, Pixmap, Bitmap, Cursor,
  491. and GContext, as defined in the file <X11/X.h>.  These
  492. resources are created by user requests, and destroyed (or
  493. freed) by user requests or when connections closed.  Most of
  494. these resources are potentially sharable between applica-
  495. tions, and in fact, windows are manipulated explicitly by
  496. window manager programs.  Fonts and cursors are typically
  497. shared automatically since the X server treats fonts spe-
  498. cially, loading and unloading font storage as needed.  GCon-
  499. texts should not be shared between applications.
  500.  
  501. Some functions return Status, an integer error indication.
  502. If the function fails, it will return a zero (0).  If the
  503. function returns a status of zero (0), it has not updated
  504. the return parameters.  Because C does not provide multiple
  505. return values, many function must return their results by
  506. writing into client-passed storage. Any pointer that is used
  507. to return a value is designated as such by the _return suf-
  508. fix as part of its name.  All other pointers passed to these
  509. functions are used for reading only.  By default, errors are
  510. handled either by a standard library function or by one that
  511. you provide.  Functions that return pointers to strings will
  512. return NULL pointers if the string does not exist.
  513.  
  514. Input events (for example, key pressed or mouse moved)
  515. __________________________
  516. The <>  has  the  meaning  defined  by  the  #  include
  517. statement of the C compiler and is a file relative to a
  518. well known directory.  On UNIX-based systems,  this  is
  519. /usr/include.
  520.  
  521.  
  522.  
  523.  
  524.                      December 18, 1987
  525.  
  526.  
  527.  
  528.  
  529.  
  530.                            - 4 -
  531.  
  532.  
  533. arrive asynchronously from the server and are queued until
  534. they are requested by a call to XNextEvent or XWindowEvent.
  535. In addition, some of the library functions (for example,
  536. XResizeWindow and XRaiseWindow) generate exposure events
  537. (that is, requests to repaint sections of a window that do
  538. not have valid contents). These events also arrive asynchro-
  539. nously, but the client may wish to explicitly wait for them
  540. by calling XSync after calling a function which may generate
  541. exposure events.
  542.  
  543. 1.2.  Naming and Argument Conventions within Xlib
  544.  
  545. Throughout Xlib, a number of conventions for naming and syn-
  546. tax of the Xlib functions have been followed.  These conven-
  547. tions are intended to make the syntax of the functions more
  548. predictable, given that you remember what information the
  549. routine may require.
  550.  
  551. The major naming conventions are:
  552.  
  553. o    To better differentiate the X symbols from the user
  554.      symbols, the library uses mixed case for external sym-
  555.      bols, and leaves lower case for variables and all upper
  556.      case for user macros, per existing convention.
  557.  
  558. o    All Xlib functions begin with a capital X.
  559.  
  560. o    The beginnings of all procedure names and symbols are
  561.      capitalized.
  562.  
  563. o    All user-visible data structures begin with a capital
  564.      X.  More generally, anything that a user might derefer-
  565.      ence begins with an capital X.
  566.  
  567. o    Macros and other symbols do not begin with a capital X.
  568.      To distinguish them from all user symbols, each word in
  569.      the macro is capitalized.
  570.  
  571. o    All elements  of or variables in a data structure are
  572.      in lower case.  Compound words, where needed, are con-
  573.      structed with underscores (_).
  574.  
  575. o    The display argument, where used, is always first in
  576.      the argument list.
  577.  
  578. o    All resource objects, where used, occur at the begin-
  579.      ning of the argument list, immediately after the
  580.      display variable.
  581.  
  582. o    When a  graphics context is present together with
  583.      another type of resource (most commonly, a drawable),
  584.      the graphics context occurs in the argument list after
  585.      the other resource.  Drawables outrank all other
  586.      resources.
  587.  
  588.  
  589.  
  590.                      December 18, 1987
  591.  
  592.  
  593.  
  594.  
  595.  
  596.                            - 5 -
  597.  
  598.  
  599. o    Source arguments always precede the destination argu-
  600.      ments in the argument list.
  601.  
  602. o    The x argument always precedes the y argument in the
  603.      argument list.
  604.  
  605. o    The width argument always precedes the height argument
  606.      in the argument list.
  607.  
  608. o    Where the x, y, width and height arguments are used
  609.      together, the x and y arguments always precede the
  610.      width and height arguments.
  611.  
  612. o    Where an array occurs in an argument list accompanied
  613.      with a count (number of elements in the array), the
  614.      array always precedes the count in the argument list.
  615.  
  616. o    Where a mask is accompanied with a structure, the mask
  617.      always precedes the pointer to the structure in the
  618.      argument list.
  619.  
  620. 1.3.  Programming Considerations
  621.  
  622. The major considerations are:
  623.  
  624. o    Keyboards are the greatest variable between different
  625.      manufacturer's workstations.  If you want your program
  626.      to be portable, you should be particularly conservative
  627.      here.
  628.  
  629. o    Many display systems have limited amounts of off-screen
  630.      memory.  If you can, you should minimize use of pixmaps
  631.      and backing store.
  632.  
  633. o    The user should have control of his screen real-estate.
  634.      Therefore, you should write your applications to react
  635.      to window management, rather than presume control of
  636.      the entire screen.  What you do inside of your top-
  637.      level window, however, is up to your application.
  638.      There is more on this topic elsewhere in the book.
  639.  
  640. 1.4.  Conventions Used in this Manual
  641.  
  642. This manual is practical, descriptive guide to all the C
  643. language functions in the Xlib library.  That is, it is
  644. organized by practical X programming tasks and describes
  645. each function in the library.  All functions that are
  646. related to a given programming task are discussed in the
  647. same chapter or section, and each provides all the related
  648. background information that is needed for that discussion.
  649. Although you can read the chapters of this manual in any
  650. order, you should start by reading Chapter 2, which explains
  651. how to connect your display to the X server.
  652.  
  653.  
  654.  
  655.  
  656.                      December 18, 1987
  657.  
  658.  
  659.  
  660.  
  661.  
  662.                            - 6 -
  663.  
  664.  
  665. The major documentation conventions are:
  666.  
  667. o    Global symbols in this manual are printed in this spe-
  668.      cial font.  These can be either procedure names, sym-
  669.      bols defined in include files, or structure names.
  670.      Arguments, user-supplied variables, are printed in
  671.      italics.
  672.  
  673. o    Most procedures are introduced by a general discussion
  674.      that may be used to distinguish this procedure from
  675.      other procedures and are followed by the procedure
  676.      declaration itself.  Each argument is then specifically
  677.      explained.  General discussion of the procedure, if any
  678.      is required, follows the arguments.  Where applicable,
  679.      the last paragraph of given explanation lists the pos-
  680.      sible Xlib error codes that can be generated by that
  681.      function.  See Section 8.10.2 for a complete discussion
  682.      of the Xlib error codes.
  683.  
  684. o    To eliminate any ambiguity between those arguments that
  685.      you pass and those that a function returns to you, the
  686.      explanations for all arguments that you pass start with
  687.      the word ``specifies''.  By contrast, the explanations
  688.      for all arguments that are returned to you start with
  689.      the word ``returns''.
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.                      December 18, 1987
  723.  
  724.  
  725.  
  726.  
  727.  
  728.                            - 7 -
  729.  
  730.  
  731.  
  732.  
  733.                             Chapter 2
  734.  
  735.                         Display Functions
  736.  
  737.  
  738.  
  739. Chapter 2 - Opening and Closing the Display Before your pro-
  740. gram can use a display, you must establish a connection to
  741. the X server driving your display.  Once you have esta-
  742. blished a connection, you then can use the Xlib macros and
  743. functions discussed in this chapter to return information
  744. about the display.  This chapter discusses how to:
  745.  
  746. o    Open (connect) the display
  747.  
  748. o    Obtain information about the display, image formats, or
  749.      a screen
  750.  
  751. o    Generate a NoOperation protocol request
  752.  
  753. o    Free client-created data
  754.  
  755. o    Close (disconnect) a display
  756.  
  757. Finally, the chapter concludes with a section that describes
  758. the operations that occur when the connection to the X
  759. server is closed.
  760.  
  761. 2.1.  Opening the Display
  762.  
  763. Use XOpenDisplay to open a connection to the X server con-
  764. trolling the specified display.  X servers may implement
  765. various types of access control mechanisms.  See section
  766. 7.11 for information about access control.  The definition
  767. for this function is:
  768.  
  769.  
  770. Display *XOpenDisplay(display_name)
  771.       char *display_name;
  772.  
  773.  
  774. display_nameSpecifies the hardware display name, which
  775.           determines the display and communications domain
  776.           to be used.  On a UNIX-based system, if the
  777.           display_name is NULL, it defaults to the DISPLAY
  778.           environment variable. On all non-UNIX systems, see
  779.           the Xlib manual associated with your operating
  780.           system to determine the default for this argument.
  781.  
  782. On UNIX-based systems, the display name or DISPLAY environ-
  783. ment variable is a string that has the format:
  784.  
  785.  
  786.  
  787.  
  788.                      December 18, 1987
  789.  
  790.  
  791.  
  792.  
  793.  
  794.                            - 8 -
  795.  
  796.  
  797.           hostname:number.screen
  798.  
  799. hostname  Specifies the name of the host machine on which
  800.           the display is physically attached.  You follow
  801.           the hostname with either a single colon (:) or a
  802.           double colon (::).  Each is discussed in the fol-
  803.           lowing paragraph.
  804.  
  805. number    Specifies the number of the display server on that
  806.           host machine.  You may optionally follow this
  807.           display number with a period (.).
  808.  
  809. screen    Specifies the number of the screen on that host
  810.           server.  Multiple screens can be connected to or
  811.           controlled by a single X server.  The screen sets
  812.           an internal variable that can be accessed by using
  813.           the DefaultScreen macro (or the XDefaultScreen
  814.           function if you are using other languages).  See
  815.           Section 2.2.1 for further information.
  816.  
  817. For example, the following would specify screen 2 of display
  818. 0 on the machine named mit-athena:
  819.  
  820. mit-athena:0.2
  821.  
  822.  
  823. The XOpenDisplay function returns a Display structure that
  824. serves as the connection to the X server and that contains
  825. all the information about that X server.  XOpenDisplay con-
  826. nects the specified hardware display to the server through
  827. TCP, UNIX domain, or DECnet stream communications protocols.
  828. If the hostname is a host machine name and a single colon
  829. (:)  separates the hostname and display number, XOpenDisplay
  830. connects using TCP streams.  If the hostname is unix and a
  831. single colon (:) separates it from the display number,
  832. XOpenDisplay connects using UNIX domain IPC streams.  If the
  833. hostname is a host machine name and a double colon (::)
  834. separates the hostname and display number, XOpenDisplay con-
  835. nects using DECnet streams.  To use DECnet, however, the X
  836. library implementation must have been built to support it.
  837. A single server can support any or all of these transport
  838. mechanisms simultaneously.
  839.  
  840. If successful, XOpenDisplay returns a pointer to a Display
  841. structure that is defined in <X11/Xlib.h>.  See Section
  842. 2.2.1, for information about using macros and functions to
  843. obtain information from the Display structure.  If XOpen-
  844. Display does not succeed, it returns a NULL.  After a suc-
  845. cessful call to XOpenDisplay, all of the screens in the
  846. display may be used by the client application.  The screen
  847. number specified in the display_name argument serves only to
  848. specify the value that will be returned by the DefaultScreen
  849. macro or the XDefaultScreen function.  You can access ele-
  850. ments of the Display and Screen structures by using the
  851.  
  852.  
  853.  
  854.                      December 18, 1987
  855.  
  856.  
  857.  
  858.  
  859.  
  860.                            - 9 -
  861.  
  862.  
  863. information macros or functions.
  864.  
  865. 2.2.  Obtaining Information About the Display, Image For-
  866. mats, or Screens
  867.  
  868. The Xlib library provides a number of useful macros and
  869. corresponding functions that return data from the Display
  870. structure.  The macros are to be used for C programming,
  871. while their corresponding function equivalents are for other
  872. language bindings.  This section discusses the:
  873.  
  874. o    Display macros
  875.  
  876. o    Image format macros
  877.  
  878. o    Screen macros
  879.  
  880. All other members of the Display structure (that is, those
  881. for which no macros are defined) are private to Xlib and
  882. must not be used.  That is, applications must never directly
  883. modify or inspect these private elements in the Display
  884. structure.
  885.  
  886. 2.2.1.  Display Macros
  887.  
  888. Once you have successfully connected to the X server that is
  889. driving a screen on your display, you can use the Xlib
  890. display macros or corresponding functions to obtain informa-
  891. tion about that display. Applications should not directly
  892. modify any part of the Display and Screen structures.  The
  893. members should be considered read-only, although they may
  894. change as the result of other operations on the display.
  895.  
  896. The following lists the C language macros, their correspond-
  897. ing function equivalents that are for other language bind-
  898. ings, and what data they both can return.
  899.  
  900.  
  901.  
  902. AllPlanes()
  903.  
  904. unsigned long XAllPlanes()
  905.  
  906.  
  907. Both return a value with all bits set on suitable for use in
  908. a plane argument to a procedure.
  909.  
  910.  
  911.  
  912. BlackPixel(display, screen)
  913.  
  914. unsigned long XBlackPixel(display, screen)
  915.       Display *display;
  916.       int screen;
  917.  
  918.  
  919.  
  920.                      December 18, 1987
  921.  
  922.  
  923.  
  924.  
  925.  
  926.                            - 10 -
  927.  
  928.  
  929. Both return the black pixel value for the specified screen.
  930.  
  931.  
  932.  
  933. ConnectionNumber(display)
  934.  
  935. int XConnectionNumber(display)
  936.       Display *display;
  937.  
  938.  
  939. Both return a connection number for the specified display.
  940. On a UNIX-based system, this is the file descriptor of the
  941. connection.
  942.  
  943.  
  944.  
  945. DefaultColormap(display, screen)
  946.  
  947. Colormap XDefaultColormap(display, screen)
  948.       Display *display;
  949.       int screen;
  950.  
  951.  
  952. Both return the default Colormap ID for allocation on the
  953. specified screen.  Most routine allocations of color should
  954. be made out of this color map.
  955.  
  956.  
  957.  
  958. DefaultDepth(display, screen)
  959.  
  960. int XDefaultDepth(display, screen)
  961.       Display *display;
  962.       int screen;
  963.  
  964.  
  965. Both return the depth (number of planes) of the default root
  966. window for the specified screen.  Other depths may also be
  967. supported on this screen.  See XMatchVisualInfo in Chapter
  968. 10 to find out how to determine what depths may be avail-
  969. able.
  970.  
  971.  
  972.  
  973. DefaultGC(display, screen)
  974.  
  975. GC XDefaultGC(display, screen)
  976.       Display *display;
  977.       int screen;
  978.  
  979.  
  980. Both return the default graphics context for the root window
  981. of the specified screen.  This GC is created for the con-
  982. venience of simple applications and contains the default GC
  983.  
  984.  
  985.  
  986.                      December 18, 1987
  987.  
  988.  
  989.  
  990.  
  991.  
  992.                            - 11 -
  993.  
  994.  
  995. components with the foreground and background pixel values
  996. initialized to the black and white pixels, respectively, for
  997. the screen.  You can modify its contents freely because it
  998. is not used in any Xlib function.
  999.  
  1000.  
  1001.  
  1002. DefaultRootWindow(display)
  1003.  
  1004. Window XDefaultRootWindow(display)
  1005.       Display *display;
  1006.  
  1007.  
  1008. Both return the root window for the default screen.
  1009.  
  1010.  
  1011.  
  1012. DefaultScreen(display)
  1013.  
  1014. int XDefaultScreen(display)
  1015.       Display *display;
  1016.  
  1017.  
  1018. Both return the default screen referenced in the XOpen-
  1019. Display routine. This macro and function should be used to
  1020. retrieve the screen number in applications that will use
  1021. only a single screen.
  1022.  
  1023.  
  1024.  
  1025. DefaultVisual(display, screen)
  1026.  
  1027. Visual *XDefaultVisual(display, screen)
  1028.       Display *display;
  1029.       int screen;
  1030.  
  1031.  
  1032. Both return the default visual type for the specified
  1033. screen.  See section 3.1 for further information about
  1034. visual types.
  1035.  
  1036.  
  1037.  
  1038. DisplayCells(display, screen)
  1039.  
  1040. int XDisplayCells(display, screen)
  1041.       Display *display;
  1042.       int screen;
  1043.  
  1044.  
  1045. Both return the number of entries in the default color map.
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.                      December 18, 1987
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.                            - 12 -
  1059.  
  1060.  
  1061. DisplayPlanes(display, screen)
  1062.  
  1063. int XDisplayPlanes(display, screen)
  1064.       Display *display;
  1065.       int screen;
  1066.  
  1067.  
  1068. Both return the depth of the root window of the specified
  1069. screen.  See the glossary for a discussion of depth.
  1070.  
  1071.  
  1072.  
  1073. DisplayString(display)
  1074.  
  1075. char *XDisplayString(display)
  1076.       Display *display;
  1077.  
  1078.  
  1079. Both return the string that was passed to XOpenDisplay when
  1080. the current display was opened. On UNIX-based systems, if
  1081. the passed string was NULL, this macro returns the value of
  1082. the DISPLAY environment variable when the current display
  1083. was opened.  This macro is useful to applications that
  1084. invoke the fork system call and want to open a new connec-
  1085. tion to the same display from the child process.
  1086.  
  1087.  
  1088.  
  1089. ImageByteOrder(display)
  1090.  
  1091. int XImageByteOrder(display)
  1092.       Display *display;
  1093.  
  1094.  
  1095. Both specify the required byte order for images for each
  1096. scanline unit in XYFormat (bitmap) or for each pixel value
  1097. in ZFormat.  The macro and function can return one of the
  1098. constants LSBFirst or MSBFirst.
  1099.  
  1100.  
  1101.  
  1102. ProtocolRevision(display)
  1103.  
  1104. int XProtocolRevision(display)
  1105.       Display *display;
  1106.  
  1107.  
  1108. Both return the minor protocol revision number of the X
  1109. server.
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.                      December 18, 1987
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.                            - 13 -
  1125.  
  1126.  
  1127. ProtocolVersion(display)
  1128.  
  1129. int XProtocolVersion(display)
  1130.       Display *display;
  1131.  
  1132.  
  1133. Both return the major version number (11) of the X protocol
  1134. associated with the connected display.
  1135.  
  1136.  
  1137.  
  1138. QLength(display)
  1139.  
  1140. int XQLength(display)
  1141.       Display *display;
  1142.  
  1143.  
  1144. Both return the length of the event queue for the connected
  1145. display.  Note that there may be more events that have not
  1146. been read into the queue yet.
  1147.  
  1148.  
  1149.  
  1150. RootWindow(display, screen)
  1151.  
  1152. Window XRootWindow(display, screen)
  1153.       Display *display;
  1154.       int screen;
  1155.  
  1156.  
  1157. Both return the root window.  This macro and function are
  1158. useful with functions that take a parent window as an argu-
  1159. ment.
  1160.  
  1161.  
  1162.  
  1163. ScreenCount(display)
  1164.  
  1165. int XScreenCount(display)
  1166.       Display *display;
  1167.  
  1168.  
  1169. Both return the number of available screens.
  1170.  
  1171.  
  1172.  
  1173. ServerVendor(display)
  1174.  
  1175. char *XServerVendor(display)
  1176.       Display *display;
  1177.  
  1178.  
  1179. Both return a pointer to a null-terminated string that pro-
  1180. vides some identification of the owner of the X server
  1181.  
  1182.  
  1183.  
  1184.                      December 18, 1987
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.                            - 14 -
  1191.  
  1192.  
  1193. implementation.
  1194.  
  1195.  
  1196.  
  1197. VendorRelease(display)
  1198.  
  1199. int XVendorRelease(display)
  1200.       Display *display;
  1201.  
  1202.  
  1203. Both return a number related to a vendor's release of the X
  1204. server.
  1205.  
  1206.  
  1207.  
  1208. WhitePixel(display, screen)
  1209.  
  1210. unsigned long XWhitePixel(display, screen)
  1211.       Display *display;
  1212.       int screen;
  1213.  
  1214.  
  1215. Both return the white pixel value for the specified screen.
  1216.  
  1217. 2.2.2.  Image Format Macros
  1218.  
  1219. Once you have successfully connected to the X server that is
  1220. driving a screen on your display, you can use the Xlib image
  1221. format macros to obtain information about image formats.
  1222.  
  1223. The following lists the C language macros, their correspond-
  1224. ing function equivalents that are for other language bind-
  1225. ings, and what data they both return.  These are often used
  1226. by toolkits as well as simple applications.
  1227.  
  1228.  
  1229.  
  1230. BitmapBitOrder(display)
  1231.  
  1232. int XBitmapBitOrder(display)
  1233.       Display *display;
  1234.  
  1235.  
  1236. Within each bitmap unit, the leftmost bit in the bitmap as
  1237. displayed on the screen is either the least or most signifi-
  1238. cant bit in the unit.  This macro and function can return
  1239. one of the constants LSBFirst or MSBFirst.
  1240.  
  1241.  
  1242.  
  1243. BitmapPad(display)
  1244.  
  1245. int XBitmapPad(display)
  1246.       Display *display;
  1247.  
  1248.  
  1249.  
  1250.                      December 18, 1987
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.                            - 15 -
  1257.  
  1258.  
  1259. Each scanline must be padded to a multiple of bits returned
  1260. by this macro or function.
  1261.  
  1262.  
  1263.  
  1264. BitmapUnit(display)
  1265.  
  1266. int XBitmapUnit(display)
  1267.       Display *display;
  1268.  
  1269.  
  1270. Both return the size of a bitmap's unit in bits.  The scan-
  1271. line is calculated in multiples of this value.
  1272.  
  1273.  
  1274.  
  1275. DisplayHeight(display, screen)
  1276.  
  1277. int XDisplayHeightMM(display, screen)
  1278.       Display *display;
  1279.       int screen;
  1280.  
  1281.  
  1282. Both return an integer that describes the height of the
  1283. screen in pixels.
  1284.  
  1285.  
  1286.  
  1287. DisplayHeightMM(display, screen)
  1288.  
  1289. int XDisplayHeightMM(display, screen)
  1290.       Display *display;
  1291.       int screen;
  1292.  
  1293.  
  1294. Both return the height of the specified screen in millime-
  1295. ters.
  1296.  
  1297.  
  1298.  
  1299. DisplayWidth(display, screen)
  1300.  
  1301. int XDisplayWidth(display, screen)
  1302.       Display *display;
  1303.       int screen;
  1304.  
  1305.  
  1306. Both return an integer that describes the width of the
  1307. screen in pixels.
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.                      December 18, 1987
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.                            - 16 -
  1323.  
  1324.  
  1325. DisplayWidthMM(display, screen)
  1326.  
  1327. int XDisplayWidthMM(display, screen)
  1328.       Display *display;
  1329.       int screen;
  1330.  
  1331.  
  1332. Both return the width of the specified screen in millime-
  1333. ters.
  1334.  
  1335. 2.2.3.  Screen Information Macros
  1336.  
  1337. Once you have successfully connected to the X server that is
  1338. driving a screen on your display, you can use the Xlib
  1339. screen information macros to obtain information about
  1340. screens.
  1341.  
  1342. The following lists the C language macros, their correspond-
  1343. ing function equivalents that are for other language bind-
  1344. ings, and what data they both can return.
  1345.  
  1346.  
  1347.  
  1348. BlackPixelOfScreen(screen)
  1349.  
  1350. unsigned long XBlackPixelOfScreen(screen)
  1351.       Screen *screen;
  1352.  
  1353.  
  1354. Both return the black pixel value of the specified screen.
  1355.  
  1356.  
  1357.  
  1358. CellsOfScreen(screen)
  1359.  
  1360. int XCellsOfScreen(screen)
  1361.       Screen *screen;
  1362.  
  1363.  
  1364. Both return the number of colormap cells of the specified
  1365. screen.
  1366.  
  1367.  
  1368.  
  1369. DefaultColormapOfScreen(screen)
  1370.  
  1371. Colormap XDefaultColormapOfScreen(screen)
  1372.       Screen *screen;
  1373.  
  1374.  
  1375. Both return the default colormap of the specified screen.
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.                      December 18, 1987
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.                            - 17 -
  1389.  
  1390.  
  1391. DefaultDepthOfScreen(screen)
  1392.  
  1393. int XDefaultDepthOfScreen(screen)
  1394.       Screen *screen;
  1395.  
  1396.  
  1397. Both return the default depth of the specified screen.
  1398.  
  1399.  
  1400.  
  1401. DefaultGCOfScreen(screen)
  1402.  
  1403. GC XDefaultGCOfScreen(screen)
  1404.       Screen *screen;
  1405.  
  1406.  
  1407. Both return the default graphics context (GC) of the speci-
  1408. fied screen.
  1409.  
  1410.  
  1411.  
  1412. DefaultScreenOfDisplay(display)
  1413.  
  1414. Screen *XDefaultScreenOfDisplay(display)
  1415.       Display *display;
  1416.  
  1417.  
  1418. Both return the default screen of the specified display.
  1419.  
  1420.  
  1421.  
  1422. DefaultVisualOfScreen(screen)
  1423.  
  1424. Visual *XDefaultVisualOfScreen(screen)
  1425.       Screen *screen;
  1426.  
  1427.  
  1428. Both return the default visual of the specified screen.  See
  1429. Section 3.1 for information on visual types.
  1430.  
  1431.  
  1432.  
  1433. DoesBackingStore(screen)
  1434.  
  1435. int XDoesBackingStore(screen)
  1436.       Screen *screen;
  1437.  
  1438.  
  1439. Both return a value indicating whether the screen supports
  1440. backing stores.  The value returned can be one of the con-
  1441. stants WhenMapped, NotUseful, or Always.  See section 3.2.4
  1442. for a discussion of the backing store.
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.                      December 18, 1987
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.                            - 18 -
  1455.  
  1456.  
  1457. DoesSaveUnders(screen)
  1458.  
  1459. Bool XDoesSaveUnders(screen)
  1460.       Screen *screen;
  1461.  
  1462.  
  1463. Both return a boolean value indicating whether the screen
  1464. supports save unders.  If True, the screen supports save
  1465. unders.  If False, the screen does not support save unders.
  1466. See section 3.2.6 for a discussion of the save under.
  1467.  
  1468.  
  1469.  
  1470. DisplayOfScreen(screen)
  1471.  
  1472. Display *XDisplayOfScreen(screen)
  1473.       Screen *screen;
  1474.  
  1475.  
  1476. Both return the display of the specified screen.
  1477.  
  1478.  
  1479.  
  1480. EventMaskOfScreen(screen)
  1481.  
  1482. long XEventMaskOfScreen(screen)
  1483.       Screen *screen;
  1484.  
  1485.  
  1486. Both return the initial root event mask for the specified
  1487. screen.
  1488.  
  1489.  
  1490.  
  1491. HeightOfScreen(screen)
  1492.  
  1493. int XHeightOfScreen(screen)
  1494.       Screen *screen;
  1495.  
  1496.  
  1497. Both return the height of the specified screen.
  1498.  
  1499.  
  1500.  
  1501. HeightMMOfScreen(screen)
  1502.  
  1503. int XHeightMMOfScreen(screen)
  1504.       Screen *screen;
  1505.  
  1506.  
  1507. Both return the height of the specified screen in millime-
  1508. ters.
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.                      December 18, 1987
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.                            - 19 -
  1521.  
  1522.  
  1523. MaxCmapsOfScreen(screen)
  1524.  
  1525. int XMaxCmapsOfScreen(screen)
  1526.       Screen *screen;
  1527.  
  1528.  
  1529. Both return the maximum number of color maps supported by
  1530. the specified screen.
  1531.  
  1532.  
  1533.  
  1534. MinCmapsOfScreen(screen)
  1535.  
  1536. int XMinCmapsOfScreen(screen)
  1537.       Screen *screen;
  1538.  
  1539.  
  1540. Both return the minimum number of color maps supported by
  1541. the specified screen.
  1542.  
  1543.  
  1544.  
  1545. PlanesOfScreen(screen)
  1546.  
  1547. int XPlanesOfScreen(screen)
  1548.       Screen *screen;
  1549.  
  1550.  
  1551. Both return the number of planes in the specified screen.
  1552.  
  1553.  
  1554.  
  1555. RootWindowOfScreen(screen)
  1556.  
  1557. Window XRootWindowOfScreen(screen)
  1558.       Screen *screen;
  1559.  
  1560.  
  1561. Both return the root window of the specified screen.
  1562.  
  1563.  
  1564.  
  1565. ScreenOfDisplay(display, screen_number)
  1566.  
  1567. Screen *XScreenOfDisplay(display, screen_number)
  1568.       Display *display;
  1569.       int screen_number;
  1570.  
  1571.  
  1572. Both return a pointer to the screen of the specified
  1573. display.
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.                      December 18, 1987
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.                            - 20 -
  1587.  
  1588.  
  1589. WhitePixelOfScreen(screen)
  1590.  
  1591. unsigned long XWhitePixelOfScreen(screen)
  1592.       Screen *screen;
  1593.  
  1594.  
  1595. Both return the white pixel value of the specified screen.
  1596.  
  1597.  
  1598.  
  1599. WidthOfScreen(screen)
  1600.  
  1601. int XWidthOfScreen(screen)
  1602.       Screen *screen;
  1603.  
  1604.  
  1605. Both return the width of the specified screen.
  1606.  
  1607.  
  1608.  
  1609. WidthMMOfScreen(screen)
  1610.  
  1611. int XWidthMMOfScreen(screen)
  1612.       Screen *screen;
  1613.  
  1614.  
  1615. Both return the width of the specified screen in millime-
  1616. ters.
  1617.  
  1618. 2.3.  Generating a NoOperation Protocol Request
  1619.  
  1620. Use XNoOp to execute a NoOperation protocol request.  The
  1621. definition for this function is:
  1622.  
  1623. XNoOp(display)
  1624.       Display *display;
  1625.  
  1626.  
  1627. display   Specifies the connection to the X server.
  1628.  
  1629. The XNoOp function sends a NoOperation request to the X
  1630. server, thereby exercising the connection.  It does not
  1631. flush the output buffer.
  1632.  
  1633. 2.4.  Freeing Client-Created Data
  1634.  
  1635. Use XFree to free any in-memory data that was created by an
  1636. Xlib function.  The definition for this function is:
  1637.  
  1638. XFree(data)
  1639.      char *data;
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.                      December 18, 1987
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.                            - 21 -
  1653.  
  1654.  
  1655. data      Specifies a pointer to the data that is to be
  1656.           freed.
  1657.  
  1658. The XFree function is a general purpose Xlib routine that
  1659. frees the specified data.
  1660.  
  1661. 2.5.  Closing the Display
  1662.  
  1663. Use XCloseDisplay to close or disconnect a display from the
  1664. X server.  The definition for this function is:
  1665.  
  1666.  
  1667. XCloseDisplay(display)
  1668.       Display *display;
  1669.  
  1670.  
  1671. display   Specifies the connection to the X server.
  1672.  
  1673. The XCloseDisplay function closes the connection to the X
  1674. server for the display specified in the Display structure.
  1675. The XCloseDisplay function destroys all windows, resource
  1676. IDs (Window, Font, Pixmap, Colormap, Cursor, and GContext),
  1677. or other resources (GCs) that the client application has
  1678. created on this display, unless the closedown mode of the
  1679. resource has been changed.  Therefore, these windows,
  1680. resource IDs, and other resources should never be referenced
  1681. again.  In addition, this function discards any output
  1682. requests that have been buffered but have not yet been sent.
  1683. Because these operations automatically (implicitly) occur if
  1684. a process exits, you normally do not have to call
  1685. XCloseDisplay explicitly.
  1686.  
  1687. 2.6.  X Server Connection Close Operations
  1688.  
  1689. When the X server's connection to a client is closed, either
  1690. by an explicit call to XCloseDisplay or by a process that
  1691. exits, the X server performs these automatic operations:
  1692.  
  1693. o    All selections (see XSetSelectionOwner) owned by the
  1694.      client are disowned.
  1695.  
  1696. o    Performs an XUngrabPointer and XUngrabKeyboard if the
  1697.      client application has actively grabbed the pointer or
  1698.      the keyboard. These functions are described in Chapter
  1699.      7.
  1700.  
  1701. o    Performs an XUngrabServer if the client has grabbed the
  1702.      server.  This function is described in Chapter 7.
  1703.  
  1704. o    Releases all passive grabs made by the client applica-
  1705.      tion.
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.                      December 18, 1987
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.                            - 22 -
  1719.  
  1720.  
  1721. o    Marks all resources (including color map entries) allo-
  1722.      cated by the client application either as permanent or
  1723.      temporary, depending on whether the close_mode argument
  1724.      is one of the constants RetainPermanent or RetainTem-
  1725.      porary.  However, this does not prevent other client
  1726.      applications from explicitly destroying the resources.
  1727.      (See below and XSetCloseDownMode in Chapter 7 for
  1728.      further information.)
  1729.  
  1730. When the mode is DestroyAll, the X server destroys all of a
  1731. client application's resources as follows:
  1732.  
  1733. o    Examines each window in the client's save-set to deter-
  1734.      mine if it is an inferior (subwindow) of a window
  1735.      created by the client.  (The save-set is a list of
  1736.      other clients windows, and windows in this list are
  1737.      referred to as a save-set window.)  If so, the X server
  1738.      reparents the save-set window to the closest ancestor
  1739.      such that the save-set window is not an inferior of a
  1740.      window created by the client.
  1741.  
  1742. o    Performs a MapWindow request on the save-set window if
  1743.      the save-set window is unmapped.  The X server does
  1744.      this even if the save-set window was not an inferior of
  1745.      a window created by the client.
  1746.  
  1747. o    Examines each window in the client's save-set, and des-
  1748.      troys all windows created by the client.
  1749.  
  1750. o    Performs the appropriate free request on each nonwindow
  1751.      resource created by the client in the server (for exam-
  1752.      ple, Font, Pixmap, Cursor, Colormap, and GContext).
  1753.  
  1754. o    Frees all colors and color map entries allocated by a
  1755.      client application.
  1756.  
  1757. Additional processing occurs when the last connection to the
  1758. X server closes.  An X server goes through a cycle of having
  1759. no connections and having some connections.  When the last
  1760. display connection to the X server closes as a result of a
  1761. connection closing with the close_mode argument DestroyAll
  1762. (that is, the X server reverts to the state of having no
  1763. connections), the X server:
  1764.  
  1765. o    Resets its state, as if it had just been started. The X
  1766.      server begins by destroying all lingering resources
  1767.      from clients that have terminated in RetainPermanent or
  1768.      RetainTemporary mode.
  1769.  
  1770. o    Deletes all but the predefined atom identifiers.
  1771.  
  1772. o    Deletes all properties on all root windows.  See
  1773.      Chapter 4 for information about properties.
  1774.  
  1775.  
  1776.  
  1777.  
  1778.                      December 18, 1987
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.                            - 23 -
  1785.  
  1786.  
  1787. o    Resets all device maps and attributes (for example, key
  1788.      click, bell volume, and acceleration) and the access
  1789.      control list.
  1790.  
  1791. o    Restores the standard root tiles and cursors.
  1792.  
  1793. o    Restores the default font path.
  1794.  
  1795. o    Restores the input focus to state PointerRoot.
  1796.  
  1797. However, the X server does not reset if you close a connec-
  1798. tion with a close_down mode argument set to RetainPermanent
  1799. or RetainTemporary.
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.                      December 18, 1987
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.                            - 24 -
  1851.  
  1852.  
  1853.  
  1854.  
  1855.                          Chapter 3
  1856.  
  1857.                       Window Related Operations
  1858.  
  1859.  
  1860.  
  1861. Chapter 3 - Window Related Operations In the X window sys-
  1862. tem, a window is a rectangular area on the screen that lets
  1863. you view graphical output.  Client applications can display
  1864. overlapping and nested windows on one or more screens that
  1865. are driven by X servers on one or more machines.  Clients
  1866. who want to create windows must first connect their program
  1867. to the X server by calling the Xlib function XOpenDisplay.
  1868. This chapter begins with a discussion of visual types and
  1869. window attributes.  The chapter continues with a discussion
  1870. of the Xlib functions you can use to:
  1871.  
  1872. o    Create windows
  1873.  
  1874. o    Destroy windows
  1875.  
  1876. o    Map windows
  1877.  
  1878. o    Unmap windows
  1879.  
  1880. o    Configure windows
  1881.  
  1882. o    Change the stacking order
  1883.  
  1884. o    Change window attributes
  1885.  
  1886. o    Translate window coordinates
  1887.  
  1888.                             Note
  1889.  
  1890.      Your application should seldom directly create
  1891.      windows, particularly top-level windows.  If you
  1892.      use a toolkit, the toolkit will do most of your
  1893.      window-creating for you. See the documentation for
  1894.      your toolkit.
  1895.  
  1896.  
  1897. This chapter also identifies the window actions that may
  1898. generate events.  See Chapter 8 for a complete discussion of
  1899. events.
  1900.  
  1901. 3.1.  Visual Types
  1902.  
  1903. On some high end displays, it may be possible to deal with
  1904. color resources in more than one way.  For example, you may
  1905. be able to deal with the display either as a 12-bit display
  1906. with arbitrary mapping of pixel to color (pseudo-color) or
  1907.  
  1908.  
  1909.  
  1910.                      December 18, 1987
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.                            - 25 -
  1917.  
  1918.  
  1919. as a 24-bit display with 8 bits of the pixel dedicated for
  1920. red, green, and blue.  These different ways of dealing with
  1921. the visual aspects of the display are called Visuals.  For
  1922. each screen of the display, there may be a list of valid
  1923. visual types supported at different depths of the display.
  1924. Because there are default windows and visual types defined
  1925. for each screen, most simple applications need not deal with
  1926. this complexity.  Xlib provides macros and functions that
  1927. return the default root window, the default depth of the
  1928. default root window, and the default visual type.  See
  1929. Chapter 2 for information on these macros and functions.
  1930. See XMatchVisualInfo in Chapter 10 for information about how
  1931. to find the visual type you need.
  1932.  
  1933. Xlib uses a Visual structure that contains information about
  1934. the possible color mapping.  The members of this structure
  1935. pertinent to this discussion are class, red_mask,
  1936. green_mask, blue_mask, bits_per_rgb, and map_entries.  The
  1937. class member specifies the possible visual classes of the
  1938. screen. It can be one of the constants StaticGray, Sta-
  1939. ticColor, TrueColor, GrayScale, PseudoColor, or DirectColor.
  1940.  
  1941. Conceptually, as each pixel is read out of memory, it goes
  1942. through a lookup stage by indexing into a colormap.  Color-
  1943. maps can be manipulated arbitrarily on some hardware, in
  1944. limited way on other hardware, and not at all on yet other
  1945. hardware. The visual types affect the color map and the RGB
  1946. values in the following ways:
  1947.  
  1948.  
  1949. o    For PseudoColor, a pixel value indexes a color map to
  1950.      produce independent RGB values, and the RGB values can
  1951.      be changed dynamically.
  1952.  
  1953. o    GrayScale is treated the same as PseudoColor, except
  1954.      the primary which drives the screen is undefined. Thus,
  1955.      the client should always store the same value for red,
  1956.      green, and blue in the color maps.
  1957.  
  1958. o    For DirectColor, a pixel value is decomposed into
  1959.      separate RGB subfields, and each subfield separately
  1960.      indexes the color map for the corresponding value.  The
  1961.      RGB values can be changed dynamically.
  1962.  
  1963. o    TrueColor is treated the same as DirectColor, except
  1964.      the color map has predefined read-only RGB values.
  1965.      These RGB values are server-dependent, but provide
  1966.      (near-)linear ramps in each primary.
  1967.  
  1968. o    StaticColor is treated the same as PseudoColor, except
  1969.      the color map has predefined read-only server-dependent
  1970.      RGB values.
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.                      December 18, 1987
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.                            - 26 -
  1983.  
  1984.  
  1985. o    StaticGray is treated the same as StaticColor, except
  1986.      the red, green, and blue values are equal for any sin-
  1987.      gle pixel value, thus resulting in shades of gray. Sta-
  1988.      ticGray with a two-entry colormap can be thought of as
  1989.      monochrome.
  1990.  
  1991. The red_mask, green_mask, and blue_mask members are only
  1992. defined for DirectColor and TrueColor.  Each has one con-
  1993. tiguous set of bits with no intersections.  The bits_per_rgb
  1994. member specifies the log base 2 of the approximate number of
  1995. distinct color values (individually) of red, green, and
  1996. blue.  Actual RGB values are unsigned 16 bit numbers.  The
  1997. map_entries member defines the number of available color map
  1998. entries in a newly created color map. For DirectColor and
  1999. TrueColor, this will be the size of an individual pixel sub-
  2000. field.  The following concepts may serve to make the expla-
  2001. nation of Visual types clearer. The screen can be color or
  2002. grayscale.  The screen can have a colormap that is writable
  2003. or read-only. A screen can also have a colormap whose
  2004. indices are decomposed into separate RGB pieces, provided
  2005. one is not on a grayscale screen. This leads to the follow-
  2006. ing diagram:
  2007.  
  2008.                Color          GrayScale
  2009.             R/O      R/W     R/O    R/W
  2010.             +-------------------------------+
  2011. Undecomposed   |Static|Pseudo|Static |Gray |
  2012.   Colormap  |Color|Color |Gray   |Scale|
  2013.             +-------------------------------+
  2014.  Decomposed |True  |Direct|
  2015.   Colormap  |Color|Color|
  2016.             +---------------+
  2017.  
  2018.  
  2019. 3.2.  Window Attributes
  2020.  
  2021. All windows have a border width of zero or more pixels, an
  2022. optional background, an input mask, an event suppression
  2023. mask, and a property list.  The window border and background
  2024. can be a solid color or a pattern, called a tile.  All win-
  2025. dows except the root have a parent and are clipped by their
  2026. parent.  If a window is stacked on top of another window, it
  2027. obscures that other window for the purpose of input.  If a
  2028. window has a background (almost all do), it obscures the
  2029. other window for purposes of output.  Attempts to output to
  2030. the obscured area will do nothing, and no input events (for
  2031. example, pointer motion) will be generated for the obscured
  2032. area.
  2033.  
  2034. Windows classified as InputOnly have only the following
  2035. attributes defined:
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.                      December 18, 1987
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.                            - 27 -
  2049.  
  2050.  
  2051. o    win_gravity
  2052.  
  2053. o    event_mask
  2054.  
  2055. o    do_not_propagate_mask
  2056.  
  2057. o    override_redirect
  2058.  
  2059. o    cursor
  2060.  
  2061. A BadMatch error is generated if you specify any other
  2062. attributes for an InputOnly window.
  2063.  
  2064. Windows have borders of a programmable width and pattern as
  2065. well as a background pattern or tile.  Pixels can be used
  2066. for solid colors.  In a program, you refer to the window
  2067. using its resource ID of type Window.  The background and
  2068. border pixmaps may be destroyed immediately after creating
  2069. the window if no further explicit references to them are to
  2070. be made.
  2071.  
  2072. A window's background pattern can be either a solid color or
  2073. a pattern.  The pattern can either be relative to the parent
  2074. or absolute.  If relative to the parent, the pattern will be
  2075. shifted appropriately to match the parent window. If abso-
  2076. lute, the pattern will be positioned in the window indepen-
  2077. dently of the parent window.
  2078.  
  2079. When windows are first created, they are not visible on the
  2080. screen.  Any output to a window not visible (not mapped) on
  2081. the screen will be discarded.  An application may wish to
  2082. create a window long before it is mapped to the screen.
  2083. When a window is eventually mapped to the screen (using
  2084. XMapWindow), the X server will generate an exposure event
  2085. for the window.
  2086.  
  2087. A window manager may override your choice as to size, border
  2088. width, and style for a window.  Your program must be
  2089. prepared to use the actual size and position of the top win-
  2090. dow, which is reported when the window is first mapped.  It
  2091. is not acceptable for a client application to resize itself
  2092. unless in direct response to a human command to do so.
  2093. Instead, your program should either use the space given to
  2094. it, or, if the space is too small for any useful work, your
  2095. program might ask the user to resize the window.  The border
  2096. of your top-level windows are considered fair game for win-
  2097. dow managers.
  2098.  
  2099. The following symbols and the XSetWindowAttributes structure
  2100. are used in the functions that follow.
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.                      December 18, 1987
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.                            - 28 -
  2115.  
  2116.  
  2117. #define CWBackPixmap          (1L<<0)
  2118. #define CWBackPixel           (1L<<1)
  2119. #define CWBorderPixmap        (1L<<2)
  2120. #define CWBorderPixel         (1L<<3)
  2121. #define CWBitGravity          (1L<<4)
  2122. #define CWWinGravity          (1L<<5)
  2123. #define CWBackingStore        (1L<<6)
  2124. #define CWBackingPlanes       (1L<<7)
  2125. #define CWBackingPixel        (1L<<8)
  2126. #define CWOverrideRedirect    (1L<<9)
  2127. #define CWSaveUnder           (1L<<10)
  2128. #define CWEventMask           (1L<<11)
  2129. #define CWDontPropagate       (1L<<12)
  2130. #define CWColormap            (1L<<13)
  2131. #define CWCursor              (1L<<14)
  2132.  
  2133.  
  2134. typedef struct {
  2135.      Pixmap background_pixmap;/* background, None, or ParentRelative */
  2136.      unsigned long background_pixel;/* background pixel */
  2137.      Pixmap border_pixmap;    /* border of the window */
  2138.      unsigned long border_pixel;/* border pixel value */
  2139.      int bit_gravity;         /* one of bit gravity values */
  2140.      int win_gravity;         /* one of the window gravity values */
  2141.      int backing_store;       /* NotUseful, WhenMapped, Always */
  2142.      unsigned long backing_planes;/* planes to be preserved if possible */
  2143.      unsigned long backing_pixel;/* value to use in restoring planes */
  2144.      Bool save_under;         /* should bits under be saved? (popups) */
  2145.      long event_mask;         /* set of events that should be saved */
  2146.      long do_not_propagate_mask;/* set of events that should not propagate */
  2147.      Bool override_redirect;  /* boolean value for override_redirect */
  2148.      Colormap colormap;       /* color map to be associated with window */
  2149.      Cursor cursor;           /* cursor to be displayed (or None) */
  2150. } XSetWindowAttributes;
  2151.  
  2152.  
  2153. The XSetWindowAttributes structure members are discussed in
  2154. the following sections.
  2155.  
  2156. 3.2.1.  The background_pixmap and background_pixel Members
  2157.  
  2158. The background_pixmap member specifies the pixmap to be used
  2159. for a window's background.  This pixmap can be of any size,
  2160. although some sizes may be faster than others.  The
  2161. background_pixel member specifies a pixel value used to
  2162. paint a window's background in a single color.
  2163.  
  2164. You can set the  background_pixmap member to a pixmap,  the
  2165. constant None, or the constant ParentRelative.  The default
  2166. value is the constant None.  You can set the
  2167. background_pixel to any pixel value.  The default value is
  2168. undefined.  If you specify a background_pixel, it overrides
  2169. either the default background_pixmap or any value you may
  2170. have set in the background_pixmap member.  All pixels in the
  2171.  
  2172.  
  2173.  
  2174.                      December 18, 1987
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.                            - 29 -
  2181.  
  2182.  
  2183. background of the window will be set to this value.
  2184.  
  2185. If you set the background_pixmap, it overrides the default
  2186. background_pixmap.  The background_pixmap and the window
  2187. must have the same depth.  Otherwise, a BadMatch error is
  2188. returned.  If you set background_pixmap to None, the window
  2189. has no defined background. If the parent window has a
  2190. background_pixmap of None, the window will also have a
  2191. background_pixmap of None.  If you set the background_pixmap
  2192. to ParentRelative:
  2193.  
  2194. o    The parent window's background_pixmap is used, but the
  2195.      child window must have the same depth as its parent.
  2196.      Otherwise, a BadMatch error is returned.
  2197.  
  2198. o    A copy of the parent window's background_pixmap is not
  2199.      made.  The parent's background_pixmap is examined each
  2200.      time the child window background_pixmap is required.
  2201.  
  2202. o    The background tile origin always aligns with the
  2203.      parent window's background tile origin. Otherwise, the
  2204.      background tile origin is always the child window ori-
  2205.      gin.
  2206.  
  2207. Setting a new background, whether by setting
  2208. background_pixmap or background_pixel, overrides any previ-
  2209. ous border.  The background_pixmap can be freed immediately
  2210. if no further explicit reference is made to it (the X server
  2211. will keep a copy to use when needed).  If you later draw
  2212. into the pixmap used for the background, X does not predict
  2213. what happens because the X implementation is free to either
  2214. make a copy of the pixmap or just use the same pixmap.
  2215.  
  2216. When regions of the window are exposed and the X server has
  2217. not retained the contents, it automatically tiles the
  2218. regions with the window's background as long as the
  2219. background_pixmap is not None.  If the background_pixmap is
  2220. None, the previous screen contents are left in place if the
  2221. window and its parent are the same depth. Otherwise, the
  2222. initial contents of the exposed regions are undefined.
  2223. Exposure events are then generated for the regions, even if
  2224. the background_pixmap is None.  See Chapter 8 for a discus-
  2225. sion of exposure event processing.
  2226.  
  2227. 3.2.2.  The border_pixmap and border_pixel Members
  2228.  
  2229. The border_pixmap member specifies the pixmap to be used for
  2230. a window's border.  This pixmap can be of any size, although
  2231. some sizes may be faster than others.  The border_pixel
  2232. member specifies a pixmap of undefined size be used for a
  2233. window's border. The border tile origin is always the same
  2234. as the background tile origin.
  2235.  
  2236. You can also set border_pixmap to CopyFromParent.  In this
  2237.  
  2238.  
  2239.  
  2240.                      December 18, 1987
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.                            - 30 -
  2247.  
  2248.  
  2249. case, the pixmap used for the border will be a copy of the
  2250. parent window's border pixmap.  The default value is the
  2251. constant CopyFromParent.  You can set the border_pixel to
  2252. any pixel value.  The default value is undefined.  If you
  2253. specify a border_pixel, it overrides either the default
  2254. border_pixmap or any value you may have set in the
  2255. border_pixmap member.  All pixels in the window's border
  2256. will be set to the border_pixel value.  Setting a new
  2257. border, whether by setting border_pixel or by setting
  2258. border_pixmap overrides any previous border.
  2259.  
  2260. If you set a border_pixmap value, it overrides the default
  2261. border_pixmap.  The border_pixmap and the window must have
  2262. the same depth.  Otherwise, a BadMatch error is returned.
  2263. If you set the border_pixmap to the constant CopyFromParent,
  2264. the parent window's border_pixmap is copied.  Subsequent
  2265. changes to the parent window do not affect the child window.
  2266. However, the child window must have the same depth as the
  2267. parent window.  Otherwise, a BadMatch error is returned.
  2268.  
  2269. The border_pixmap can be freed immediately if no further
  2270. explicit reference is made to it.  If you later draw into
  2271. the pixmap used for the border, X does not predict what hap-
  2272. pens because the X implementation is free to either make a
  2273. copy of the pixmap or use the same pixmap each time the win-
  2274. dow border is repainted.
  2275.  
  2276. Output to a window is always clipped to the inside of the
  2277. window. Therefore, graphics operations never affect the win-
  2278. dow border.  Borders are added to the window size specified.
  2279.  
  2280. 3.2.3.  The bit_gravity and win_gravity Members
  2281.  
  2282. Bit gravity defines which region of the window should be
  2283. retained when the window is resized. The default value for
  2284. the bit_gravity member is the constant ForgetGravity.  Win-
  2285. dow gravity allows you to  define how the window should be
  2286. repositioned if its parent is resized. The default value for
  2287. the win_gravity member is the constant NorthWestGravity.
  2288. See XGetWindowAttributes in Section 4.1 for a description of
  2289. the possible values you can set these to.
  2290.  
  2291. 3.2.4.  The backing_store Member
  2292.  
  2293. Some implementations of the X server may choose to maintain
  2294. the contents of windows.  If the X server maintains the con-
  2295. tents of a window, the off-screen saved pixels are known as
  2296. backing store.  The backing_store member advises the X
  2297. server on what to do with the contents of a window.  You can
  2298. set this member to NotUseful, WhenMapped, or Always.  The
  2299. default value is NotUseful.
  2300.  
  2301. A backing_store of WhenMapped advises the X server that
  2302. maintaining contents of obscured regions when the window is
  2303.  
  2304.  
  2305.  
  2306.                      December 18, 1987
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.                            - 31 -
  2313.  
  2314.  
  2315. mapped would be beneficial.  A backing_store of Always
  2316. advises the X server that maintaining contents even when the
  2317. window is unmapped would be beneficial. Even if the window
  2318. is larger than its parent, this is a request to the X server
  2319. to  maintain complete contents, not just the region within
  2320. the parent window boundaries. If the X server maintains con-
  2321. tents, exposure events will not be generated, but the X
  2322. server may stop maintaining contents at any time. A
  2323. backing_store of NotUseful advises the X server that main-
  2324. taining contents is unnecessary, although some X implementa-
  2325. tions may still choose to maintain contents and, therefore,
  2326. not generate exposure events.
  2327.  
  2328. 3.2.5.  The backing_planes and backing_pixel Members
  2329.  
  2330. The default value for the backing_planes member is all ones.
  2331. It indicates (with one bits) which bit planes of the window
  2332. hold dynamic data that must be preserved in backing_stores
  2333. and during save_unders.  The default value for the
  2334. backing_pixel member is zero (0).  It specifies what values
  2335. to use in planes not covered by backing_planes. The X server
  2336. is free to save only the specified bit planes in the
  2337. backing_store or the save_under and is free to regenerate
  2338. the remaining planes with the specified pixel value.  Any
  2339. extraneous bits (that is, those beyond the specified depth
  2340. of the window) in these values may be simply ignored.
  2341.  
  2342. 3.2.6.  The save_under Member
  2343.  
  2344. Some server implementations may preserve bits of windows
  2345. under other windows.  This is not the same as preserving the
  2346. contents of a window for you.  You may get better visual
  2347. appeal if transient windows (for example, pop-up menus)
  2348. request that the system preserve the bits under them, so the
  2349. temporarily obscured applications do not have to repaint.
  2350.  
  2351. The default value for the save_under member is False.  If
  2352. save_under is True, the X server is advised that, when this
  2353. window is mapped, saving the contents of windows it obscures
  2354. would be beneficial.
  2355.  
  2356. 3.2.7.  The event_mask and do_not_propagate_mask Members
  2357.  
  2358. The event_mask defines which events the client is interested
  2359. in for this window (or, for some event types, inferiors of
  2360. the window). The do_not_propagate_mask defines which events
  2361. should not be propagated to ancestor windows when no client
  2362. has the event type selected in this window.  These masks are
  2363. the bitwise inclusive OR of one or more of the valid event
  2364. mask bits.  You can specify that no maskable events are
  2365. reported by passing the constant NoEventMask.  The default
  2366. value for these members is the empty set.  See Section 8.3
  2367. for information on the event mask and events.
  2368.  
  2369.  
  2370.  
  2371.  
  2372.                      December 18, 1987
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.                            - 32 -
  2379.  
  2380.  
  2381. 3.2.8.  The override_redirect Member
  2382.  
  2383. The default value for the override_redirect member is False.
  2384. Override_redirect specifies whether map and configure
  2385. requests on this window should override a Substruc-
  2386. tureRedirectMask on the parent. Window manages use this
  2387. information to avoid tampering with pop-up windows.
  2388.  
  2389. 3.2.9.  The colormap Member
  2390.  
  2391. The default value for the colormap member is CopyFromParent.
  2392. The colormap member specifies which color map, if any, best
  2393. reflects the true colors of the window. The colormap must
  2394. have the same visual type as the window.  Otherwise, a Bad-
  2395. Match error is returned. X servers capable of supporting
  2396. multiple hardware color maps may use this information, and
  2397. window managers may use it for InstallColormap requests.  If
  2398. you set the colormap member to CopyFromParent, the parent
  2399. window's color map is copied and used by its child.  Subse-
  2400. quent changes to the parent window do not affect the child
  2401. window.  However, the child window must have the same visual
  2402. type as the parent. Otherwise, a BadMatch error is returned.
  2403. The parent window must not have a color map of None.  Other-
  2404. wise, a BadMatch error is returned.
  2405.  
  2406. 3.2.10.  The cursor Member
  2407.  
  2408. The default value for the cursor member is the constant
  2409. None.  If a cursor is specified, it will be used whenever
  2410. the pointer is in the window. If None is specified, the
  2411. parent's cursor will be used when the pointer is in the win-
  2412. dow, and any change in the parent's cursor will cause an
  2413. immediate change in the displayed cursor.  The cursor may be
  2414. freed immediately if no further explicit reference to it is
  2415. made by calling XFreeCursor.  See Section 6.8.2 for further
  2416. information.
  2417.  
  2418. 3.2.11.  Default Values for XSetWindowAttributes Members
  2419.  
  2420. The following table lists the default values for each member
  2421. in the XSetWindowAttributes structure.
  2422.  
  2423. ________________________________________
  2424. Member                  Default Value
  2425. ________________________________________
  2426. background_pixmap       None
  2427. background_pixel        Undefined
  2428. border_pixmap           CopyFromParent
  2429. border_pixel            Undefined
  2430. bit_gravity             ForgetGravity
  2431. win_gravity             NorthWestGravity
  2432. backing_store           NotUseful
  2433. backing_planes          All ones
  2434. backing_pixel           0 (zero)
  2435.  
  2436.  
  2437.                      December 18, 1987
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.                            - 33 -
  2444.  
  2445.  
  2446. ________________________________________
  2447. Member                  Default Value
  2448. ________________________________________
  2449. save_under              False
  2450. event_mask              empty set
  2451. do_not_propagate_mask   empty set
  2452. override_redirect       False
  2453. colormap                CopyFromParent
  2454. cursor                  None
  2455. ________________________________________
  2456.  
  2457.  
  2458. 3.3.  Creating Windows
  2459.  
  2460. Xlib provides basic ways of creating windows.  See the X
  2461. toolkit documentation for more information.  If you create
  2462. your own top level windows (direct children of the root win-
  2463. dow) the rules enumerated below must be observed for appli-
  2464. cations to interact reasonably across differing styles of
  2465. window management.
  2466.  
  2467. You should never fight with a window manager for size or
  2468. placement of your top-level window(s).  Toolkits often sup-
  2469. ply routines specifically for creating and placing top level
  2470. windows.  If you do not use a toolkit, you should provide
  2471. some standard information or ``hints'' to the window manager
  2472. by using the utility functions described in Chapter 10.
  2473.  
  2474. The policy guidelines for window creation are:
  2475.  
  2476. 1.   An application, by listening to the first exposure
  2477.      event, must be able to deal with whatever size window
  2478.      it gets, even if this means that the application just
  2479.      prints a message, like ``Please make me bigger,'' in
  2480.      its window.
  2481.  
  2482. 2.   An application should only attempt to resize or move
  2483.      its top-level window in direct response to a user
  2484.      request.  An application is free to resize or move the
  2485.      children of its top-level window as necessary.  (Toolk-
  2486.      its often have facilities for automatic relayout.)  If
  2487.      a request to change the size of its top-level window
  2488.      fails, the application must not fight with the window
  2489.      manager.
  2490.  
  2491. 3.   If an application does not use a toolkit that automati-
  2492.      cally sets standard window properties, that application
  2493.      should set these properties for the top-level window
  2494.      before mapping it.  To set standard window properties
  2495.      for a top-level window, use XSetStandardProperties.
  2496.      See Chapter 9 for further information.
  2497.  
  2498. The low-level functions provided by Xlib to create an
  2499. unmapped subwindow for a specified parent window are
  2500.  
  2501.  
  2502.  
  2503.                      December 18, 1987
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.                            - 34 -
  2510.  
  2511.  
  2512. XCreateWindow and XCreateSimpleWindow.  XCreateWindow is a
  2513. more general function that allows you to set specific window
  2514. attributes when you create it.  XCreateSimpleWindow creates
  2515. a window that inherits its attributes from its parent win-
  2516. dow.  That is, you do not set specific attributes when you
  2517. create a  simple window.
  2518.  
  2519. The X server acts as if InputOnly windows do not exist for
  2520. the purposes of graphics requests, exposure processing, and
  2521. VisibilityNotify events.  An InputOnly window cannot be used
  2522. as a drawable (that is, as a source or destination for
  2523. graphics requests).  InputOnly and InputOutput windows act
  2524. identically in other respects (properties, grabs, input con-
  2525. trol, and so on).  Extension packages may define other
  2526. classes of windows.
  2527.  
  2528. The definition for XCreateWindow is:
  2529.  
  2530. Window XCreateWindow(display, parent, x, y, width, height, border_width, depth,
  2531.                        class, visual, valuemask, attributes)
  2532.       Display *display;
  2533.       Window parent;
  2534.       int x, y;
  2535.       unsigned int width, height;
  2536.       unsigned int border_width;
  2537.       int depth;
  2538.       unsigned int class;
  2539.       Visual *visual
  2540.       unsigned long valuemask;
  2541.       XSetWindowAttributes *attributes;
  2542.  
  2543.  
  2544. display   Specifies the connection to the X server.
  2545.  
  2546. parent    Specifies the parent window ID.
  2547.  
  2548. x
  2549. y         Specify the x and y coordinates.  These coordi-
  2550.           nates are the top left outside corner of the
  2551.           created window's borders and are relative to the
  2552.           inside of the parent window's borders.
  2553.  
  2554. width
  2555. height    Specify the width and height.  These are the
  2556.           created window's inside dimensions.  These dimen-
  2557.           sions do not include the created window's borders,
  2558.           which are entirely outside of the window.  The
  2559.           dimensions must be nonzero. Otherwise, a BadValue
  2560.           error is returned.
  2561.  
  2562. border_widthSpecifies, in pixels, the width of the created
  2563.           window's border.  The border_width for an Inpu-
  2564.           tOnly window must be zero (0).  Otherwise, a Bad-
  2565.           Match error is returned.
  2566.  
  2567.  
  2568.  
  2569.                      December 18, 1987
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.                            - 35 -
  2576.  
  2577.  
  2578. depth     A depth of zero for class InputOutput or CopyFrom-
  2579.           Parent means the depth is taken from the parent.
  2580.  
  2581. class     Specifies the created window's class.  You can
  2582.           pass one of these constants:  InputOutput, Inpu-
  2583.           tOnly, or CopyFromParent.  A class of CopyFrom-
  2584.           Parent means the class is taken from the parent.
  2585.  
  2586. visual    Specifies the visual type.  A visual of CopyFrom-
  2587.           Parent means the visual type is taken from the
  2588.           parent.
  2589.  
  2590. valuemask Specifies which window attributes are defined in
  2591.           the attributes argument.  This mask is the bitwise
  2592.           inclusive OR of the valid attribute mask bits.  If
  2593.           valuemask is zero (0), the rest is ignored, and
  2594.           the attributes are not referenced.
  2595.  
  2596. attributesAttributes of the window to be set at creation
  2597.           time should be set in this structure.  The
  2598.           valuemask should have the appropriate bits set to
  2599.           indicate which attributes have been set in the
  2600.           structure.  See Section 3.2 for further informa-
  2601.           tion.
  2602.  
  2603. The XCreateWindow function creates an unmapped subwindow for
  2604. a specified parent window, returns the window ID of the
  2605. created window, and causes the X server to generate a
  2606. CreateNotify event.  The created window is placed on top in
  2607. the stacking order with respect to siblings.
  2608.  
  2609. For class InputOutput, the visual type and depth must be a
  2610. combination supported for the screen.  Otherwise, a BadMatch
  2611. error is returned.  The depth need not be the same as the
  2612. parent, but the parent must not be a window of class Inpu-
  2613. tOnly.  Otherwise, a BadMatch error is generated.  For an
  2614. InputOnly window the depth must be zero (0), and the visual
  2615. must be one supported by the screen.  If either of these
  2616. conditions are not met, a BadMatch error is generated.  The
  2617. parent window, however, may have any depth and class.  The
  2618. only window attributes defined for InputOnly windows are
  2619. win_gravity, event_mask, do_not_propagate_mask,
  2620. override_redirect, and cursor.  If you specify any other
  2621. window attribute for an InputOnly window, a BadMatch error
  2622. is returned.
  2623.  
  2624. The errors that can be generated by XCreateWindow are BadAl-
  2625. loc BadColor, BadCursor, BadMatch, BadPixmap, BadValue, and
  2626. BadWindow.
  2627.  
  2628.  
  2629. Use XCreateSimpleWindow to create an unmapped InputOutput
  2630. subwindow of the specified parent window.  The definition
  2631. for this function is:
  2632.  
  2633.  
  2634.  
  2635.                      December 18, 1987
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.                            - 36 -
  2642.  
  2643.  
  2644. Window XCreateSimpleWindow(display, parent, x, y, width, height, border_width,
  2645.                              border, background)
  2646.       Display *display;
  2647.       Window parent;
  2648.       int x, y;
  2649.       unsigned int width, height, border_width;
  2650.       unsigned long border;
  2651.       unsigned long background;
  2652.  
  2653.  
  2654. display   Specifies the connection to the X server.
  2655.  
  2656. parent    Specifies the parent window ID.
  2657.  
  2658. x
  2659. y         Specify the x and y coordinates.  These coordi-
  2660.           nates are the top left outside corner of the new
  2661.           window's borders and are relative to the inside of
  2662.           the parent window's borders.
  2663.  
  2664. width
  2665. height    Specify the width and height.  These are the
  2666.           created window's inside dimensions.  These dimen-
  2667.           sions do not include the created window's borders,
  2668.           which are entirely outside of the window.  The
  2669.           dimensions must be nonzero.  Otherwise, a BadValue
  2670.           error is returned.
  2671.  
  2672. border_widthSpecifies, in pixels, the width of the created
  2673.           window's border.  The border_width for an Inpu-
  2674.           tOnly window must be zero (0).  Otherwise, a Bad-
  2675.           Match error is returned.
  2676.  
  2677. border    Specifies the border pixel of the window.
  2678.  
  2679. backgroundSpecifies the pixel value that you want to set for
  2680.           the specified window's background.
  2681.  
  2682.  
  2683. The XCreateSimpleWindow function creates an unmapped Inpu-
  2684. tOutput subwindow for a specified parent window, returns the
  2685. window ID of the created window, and causes the X server to
  2686. generate a CreateNotify event.  The created window is placed
  2687. on top in the stacking order with respect to siblings.  Any
  2688. part of the window that extends outside its parent window
  2689. will be clipped.  XCreateSimpleWindow inherits its depth,
  2690. class, and visual from its parent.  All other window attri-
  2691. butes have their default values.
  2692.  
  2693. The created window is not yet displayed (mapped) on the
  2694. user's display.  To display the window, call XMapWindow.
  2695. The new window will initially use the same cursor as its
  2696. parent. A new cursor may, of course, be defined for the new
  2697. window by calling XDefineCursor.  The window will not be
  2698.  
  2699.  
  2700.  
  2701.                      December 18, 1987
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.                            - 37 -
  2708.  
  2709.  
  2710. visible on the screen unless it and all of its ancestors are
  2711. mapped, and it is not obscured by any of its ancestors.  The
  2712. window is placed on top of the stacking order with respect
  2713. to its siblings.  In addition, the new window's cursor will
  2714. be None.
  2715.  
  2716. The errors that can be generated by XCreateSimpleWindow are
  2717. BadAlloc, BadValue, and BadWindow.
  2718.  
  2719. 3.4.  Destroying Windows
  2720.  
  2721. Xlib provides functions with which you can destroy a window
  2722. or  destroy all subwindows of a window.
  2723.  
  2724.  
  2725. Use XDestroyWindow to destroy a window and all of its
  2726. subwindows. The definition for this function is:
  2727.  
  2728. XDestroyWindow(display, w)
  2729.       Display *display;
  2730.       Window w;
  2731.  
  2732.  
  2733. display   Specifies the connection to the X server.
  2734.  
  2735. w         Specifies the window ID.
  2736.  
  2737. The XDestroyWindow function destroys the specified window as
  2738. well as all of its subwindows and causes the X server to
  2739. generate a DestroyNotify event for each window.  The window
  2740. should never again be referenced.  If the window specified
  2741. by the w argument is mapped, it is unmapped automatically.
  2742. The window and all of its inferiors are then destroyed, and
  2743. a DestroyNotify event is generated for each window.  The
  2744. ordering of the DestroyNotify events is such that for any
  2745. given window being destroyed, DestroyNotify is generated on
  2746. any inferiors of the window before being generated on the
  2747. window itself.  The ordering among siblings and across
  2748. subhierarchies is not otherwise constrained.  If the window
  2749. you specified is a root window, no windows are destroyed.
  2750. Destroying a mapped  window will generate exposure events on
  2751. other windows that were obscured by the window being des-
  2752. troyed.
  2753.  
  2754. The error that can be generated by XDestroyWindow is BadWin-
  2755. dow.
  2756.  
  2757.  
  2758. Use XDestroySubwindows to destroy all subwindows of a speci-
  2759. fied window. The definition for this function is:
  2760.  
  2761. XDestroySubwindows(display, w)
  2762.       Display *display;
  2763.       Window w;
  2764.  
  2765.  
  2766.  
  2767.                      December 18, 1987
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.                            - 38 -
  2774.  
  2775.  
  2776. display   Specifies the connection to the X server.
  2777.  
  2778. w         Specifies the window ID.
  2779.  
  2780. The XDestroySubwindows function destroys all inferior win-
  2781. dows of the specified window, in bottom to top stacking
  2782. order.  It causes the X server to generate a DestroyNotify
  2783. event for each window.  If any mapped subwindows were actu-
  2784. ally destroyed, XDestroySubwindows causes the X sever to
  2785. generate exposure events on the specified window.  This is
  2786. much more efficient than deleting many windows one at a time
  2787. because much of the work need only be performed once for all
  2788. of the windows rather than for each window.  The subwindows
  2789. should never again be referenced.
  2790.  
  2791. The error that can be generated by XDestroySubwindows is
  2792. BadWindow.
  2793.  
  2794.                             Note
  2795.  
  2796.      XCloseDisplay automatically destroys all windows
  2797.      that have been created on that server if it is the
  2798.      last copy of the connection.  (Remember that under
  2799.      UNIX, fork will duplicate open connections).
  2800.  
  2801.  
  2802. 3.5.  Mapping Windows
  2803.  
  2804. A window manager may want to control the placement of
  2805. subwindows.  If SubstructureRedirectMask has been selected
  2806. by a window manager on a parent window (usually a root win-
  2807. dow), a map request initiated by other clients on a child
  2808. window is not performed, and the window manager would be
  2809. sent a MapRequest event.  However, if the override_redirect
  2810. flag on the child had been set to True (usually only on
  2811. pop-up menus), the map request would be performed.
  2812.  
  2813. A tiling window manager might decide to reposition and
  2814. resize other client's windows and then decide to map the
  2815. window at its final location.  A window manager that wants
  2816. to provide decoration might reparent the child into a frame
  2817. first.  See Section 3.2.7 and Chapter 8 for further informa-
  2818. tion.  Only a single client at a time can select for Sub-
  2819. structureRedirectMask.
  2820.  
  2821. Similarly, a single client can select for ResizeRedirectMask
  2822. on a parent window.  Then, any attempt to resize the window
  2823. is suppressed, and the client (usually, a window manager)
  2824. receives a ResizeRequest event.  These mechanisms allow
  2825. arbitrary placement policy to be enforced by an external
  2826. window manager.
  2827.  
  2828. A window is considered mapped if a XMapWindow call has been
  2829. made on it.  It may not be visible on the screen for one of
  2830.  
  2831.  
  2832.  
  2833.                      December 18, 1987
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839.                            - 39 -
  2840.  
  2841.  
  2842. the following reasons:
  2843.  
  2844. o    It is obscured by another opaque sibling window.
  2845.  
  2846. o    One of its ancestors is not mapped.
  2847.  
  2848. o    It is entirely clipped by an ancestor.
  2849.  
  2850. Exposure events will be generated for the window when part
  2851. or all of it becomes visible on the screen. A client will
  2852. only receive the exposure events if it has asked for them
  2853. using XSelectInput.  Windows retain their position in the
  2854. stacking order when unmapped.
  2855.  
  2856.  
  2857. Use XMapWindow to map the specified window. The definition
  2858. for this function is:
  2859.  
  2860. XMapWindow(display, w)
  2861.       Display *display;
  2862.       Window w;
  2863.  
  2864.  
  2865. display   Specifies the connection to the X server.
  2866.  
  2867. w         Specifies the window ID.
  2868.  
  2869. The XMapWindow function maps the window and all of its
  2870. subwindows which have had map requests.  A subwindow will
  2871. appear on the screen as long as all of its ancestors are
  2872. mapped and not obscured by a sibling or are not clipped by
  2873. an ancestor.  Mapping a window that has an unmapped ancestor
  2874. does not display the window but marks it as eligible for
  2875. display when the ancestor becomes mapped.  Such a window is
  2876. called unviewable.  When all its ancestors are mapped, the
  2877. window becomes viewable and will be visible on the screen if
  2878. it is not obscured by any sibling or ancestor.  This func-
  2879. tion has no effect if the window is already mapped.
  2880.  
  2881. If the override_redirect member of the XSetWindowAttributes
  2882. structure is False, and if some other client has selected
  2883. SubstructureRedirectMask on the parent window, then the X
  2884. server generates a MapRequest event, and the XMapWindow
  2885. function does not map the window.  Otherwise, the window is
  2886. mapped, and the X server generates a MapNotify event.
  2887.  
  2888. If the window becomes viewable and no earlier contents for
  2889. it are remembered, XMapWindow tiles the window with its
  2890. background.  If no background was defined for the window,
  2891. the existing screen contents are not altered, and the X
  2892. server generates one or more Expose events.  If a
  2893. backing_store was maintained while the window was unmapped,
  2894. no Expose events are generated.  If a backing_store will now
  2895. be maintained, a full-window exposure is always generated.
  2896.  
  2897.  
  2898.  
  2899.                      December 18, 1987
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.                            - 40 -
  2906.  
  2907.  
  2908. Otherwise, only visible regions may be reported.  Similar
  2909. tiling and exposure take place for any newly viewable infe-
  2910. riors.
  2911.  
  2912. If the window is an InputOutput window, XMapWindow generates
  2913. Expose events on each InputOutput window that it causes to
  2914. become displayed.  If the client maps and paints the window,
  2915. and if the client begins processing events, the window will
  2916. be painted twice.  To avoid this, the client should call
  2917. XSelectInput for exposure events, and map the window. Then,
  2918. the client should process input events normally.  The event
  2919. list will include Expose for each window that has appeared
  2920. on the screen. The client's normal response to an Expose
  2921. event should be to repaint the window.  This method usually
  2922. leads to simpler programs and to proper interaction with
  2923. window managers.
  2924.  
  2925. The error that can be generated by XMapWindow is BadWindow.
  2926.  
  2927.  
  2928. Use XMapRaised to map and raise a window.  The definition
  2929. for this function is:
  2930.  
  2931. XMapRaised(display, w)
  2932.       Display *display;
  2933.       Window w;
  2934.  
  2935.  
  2936. display   Specifies the connection to the X server.
  2937.  
  2938. w         Specifies the window ID.
  2939.  
  2940. The XMapRaised function essentially is similar to XMapWindow
  2941. in that it maps the window and all of its subwindows which
  2942. have had map requests.  However, it also raises the speci-
  2943. fied window to the top of the stack.  See the XMapWindow
  2944. description for additional information.
  2945.  
  2946. The error that can be generated by XMapRaised is BadWindow.
  2947.  
  2948.  
  2949. Use XMapSubwindows to map all subwindows for a specified
  2950. window. The definition for this function is:
  2951.  
  2952. XMapSubwindows(display, w)
  2953.       Display *display;
  2954.       Window w;
  2955.  
  2956.  
  2957. display   Specifies the connection to the X server.
  2958.  
  2959. w         Specifies the window ID.
  2960.  
  2961. The XMapSubwindows function maps all subwindows for a
  2962.  
  2963.  
  2964.  
  2965.                      December 18, 1987
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.                            - 41 -
  2972.  
  2973.  
  2974. specified window in top-to-bottom stacking order.  The X
  2975. server to generate an Expose event on each newly displayed
  2976. window.  This is much more efficient than mapping many win-
  2977. dows one at a time, because the server needs only perform
  2978. much of the work once for all of the windows rather than for
  2979. each window.
  2980.  
  2981. The error that can be generated by XMapSubwindows is BadWin-
  2982. dow.
  2983.  
  2984. 3.6.  Unmapping Windows
  2985.  
  2986. Xlib provides functions with which you can unmap a window or
  2987. all subwindows.
  2988.  
  2989.  
  2990. Use XUnmapWindow to unmap a window. The definition for this
  2991. function is:
  2992.  
  2993. XUnmapWindow(display, w)
  2994.       Display *display;
  2995.       Window w;
  2996.  
  2997.  
  2998. display   Specifies the connection to the X server.
  2999.  
  3000. w         Specifies the window ID.
  3001.  
  3002. The XUnmapWindow function unmaps the specified window and
  3003. causes the X server to generate an UnmapNotify event.  If
  3004. the specified window is already unmapped, XUnmapWindow has
  3005. no effect.  Normal exposure processing on formerly obscured
  3006. windows is performed.  Any child window will no longer be
  3007. visible until another map call is made on the parent.  In
  3008. other words, the subwindows are still mapped but not visible
  3009. until the parent is mapped.  Unmapping a window will gen-
  3010. erate exposure events on windows that were formerly obscured
  3011. by it and its children.
  3012.  
  3013. The error that can be generated by XUnmapWindow is BadWin-
  3014. dow.
  3015.  
  3016.  
  3017. Use XUnmapSubwindows to unmap all subwindows for a specified
  3018. window. The definition for this function is:
  3019.  
  3020. XUnmapSubwindows(display, w)
  3021.       Display *display;
  3022.       Window w;
  3023.  
  3024.  
  3025. display   Specifies the connection to the X server.
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.                      December 18, 1987
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.                            - 42 -
  3038.  
  3039.  
  3040. w         Specifies the window ID.
  3041.  
  3042. The XUnmapSubwindows function unmaps all subwindows for the
  3043. specified window in bottom to top stacking order.  It causes
  3044. the X server to generate an UnmapNotify event on each
  3045. subwindow and exposure events on formerly obscured windows.
  3046. Using this function is much more efficient than unmapping
  3047. multiple windows one at a time, because the server needs
  3048. only perform much of the work once for all of the windows
  3049. rather than for each window.
  3050.  
  3051. The error that can be generated by XUnmapSubwindows is
  3052. BadWindow.
  3053.  
  3054. 3.7.  Configuring Windows
  3055.  
  3056. Xlib provides functions with which you can move a window,
  3057. resize a window, move and resize a window, or change a
  3058. window's border width.  The most general interface to confi-
  3059. guring windows, XConfigureWindow, uses the XWindowChanges
  3060. structure, which contains:
  3061.  
  3062. #define CWX                   (1<<0)
  3063. #define CWY                   (1<<1)
  3064. #define CWWidth               (1<<2)
  3065. #define CWHeight              (1<<3)
  3066. #define CWBorderWidth         (1<<4)
  3067. #define CWSibling             (1<<5)
  3068. #define CWStackMode           (1<<6)
  3069.  
  3070. typedef struct {
  3071.      int x, y;
  3072.      int width, height;
  3073.      int border_width;
  3074.      Window sibling;
  3075.      int stack_mode;
  3076. } XWindowChanges;
  3077.  
  3078.  
  3079. The following paragraphs discuss the members of this struc-
  3080. ture and the processing that occurs for XConfigureWindow.
  3081.  
  3082. The x and y members specify the x and y coordinates relative
  3083. to the parent's origin and indicate the position of the
  3084. upper left outer corner of the window.  The width and height
  3085. members specify the inside size of the window, not including
  3086. the border.  These arguments must be nonzero.  Otherwise, a
  3087. BadValue error is generated.  Attempts to configure a root
  3088. window have no effect.
  3089.  
  3090. The border_width member specifies the width of the border in
  3091. pixels.  Note that changing just the border_width leaves the
  3092. outer-left corner of the window in a fixed position, but
  3093. moves the absolute position of the window's origin.  A
  3094.  
  3095.  
  3096.  
  3097.                      December 18, 1987
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.                            - 43 -
  3104.  
  3105.  
  3106. BadMatch error is generated if you attempt to make the
  3107. border_width of an InputOnly window nonzero.
  3108.  
  3109. The sibling member specifies the sibling window for stacking
  3110. operations.  The stack_mode member can be one of these con-
  3111. stants:  Above, Below, TopIf, BottomIf, or Opposite.
  3112.  
  3113. If the override_redirect attribute of the window is False,
  3114. and if some other client has selected Substruc-
  3115. tureRedirectMask on the parent, then the X server generates
  3116. a ConfigureRequest event, and no further processing is per-
  3117. formed.  Otherwise, if some other client has selected Resiz-
  3118. eRedirectMask on the window and the inside width or height
  3119. of the window is being changed, a ResizeRequest event is
  3120. generated, and the current inside width and height are used
  3121. instead in the following.  Note that the override_redirect
  3122. attribute of the window has no effect on ResizeRedirectMask
  3123. and that SubstructureRedirectMask on the parent has pre-
  3124. cedence over ResizeRedirectMask on the window.
  3125.  
  3126. The geometry of the window is changed as specified, the win-
  3127. dow is restacked among siblings, and a ConfigureNotify event
  3128. is generated.  X generates GravityNotify events after gen-
  3129. erating ConfigureNotify events.  If the inside width or
  3130. height of the window has actually changed, then children of
  3131. the window are affected as described below.
  3132.  
  3133. Exposure processing is performed on formerly obscured win-
  3134. dows, including the window itself and its inferiors, if
  3135. regions of them were obscured but now are not.  As a result
  3136. of increasing the width or height, exposure processing is
  3137. also performed on any new regions of the window and any
  3138. regions where window contents are lost.
  3139.  
  3140. If the inside width or height of a window is not changed,
  3141. and if the window is moved or its border is changed, then
  3142. the contents of the window are not lost but move with the
  3143. window.  Changing the inside width or height of the window
  3144. causes its contents to be moved or lost, depending on the
  3145. bit_gravity of the window, and causes children to be recon-
  3146. figured, depending on their win_gravity. For a change of
  3147. width and height, the (x, y) pairs are defined:
  3148.  
  3149.  
  3150. _______________________________________
  3151. Gravity Direction   Coordinates
  3152. _______________________________________
  3153. NorthWestGravity
  3154.                     (0, 0)
  3155.  
  3156. NorthGravity
  3157.                     (Width/2, 0)
  3158.  
  3159. NorthEastGravity
  3160.                     (Width, 0)
  3161.  
  3162. WestGravity
  3163.                     (0, Height/2)
  3164.  
  3165. CenterGravity
  3166.                     (Width/2, Height/2)
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.                      December 18, 1987
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.                            - 44 -
  3179.  
  3180.  
  3181. EastGravity
  3182.                     (Width, Height/2)
  3183.  
  3184. SouthWestGravity
  3185.                     (0, Height)
  3186.  
  3187. SouthGravity
  3188.                     (Width/2, Height)
  3189.  
  3190. SouthEastGravity
  3191.                     (Width, Height)
  3192.  
  3193. _______________________________________
  3194.  
  3195.  
  3196. When a window with one of these bit_gravities is resized,
  3197. the corresponding pair defines the change in position of
  3198. each pixel in the window.  When a window with one of these
  3199. win_gravities has its parent window resized, the correspond-
  3200. ing pair defines the change in position of the window within
  3201. the parent.  When a window is so repositioned, a GravityNo-
  3202. tify event is generated.
  3203.  
  3204. A bit_gravity of StaticGravity indicates that the contents
  3205. or origin should not move relative to the origin of the root
  3206. window.  If the change in size of the window is coupled with
  3207. a change in position (x, y), then for bit_gravity the change
  3208. in position of each pixel is (-x, -y), and for win_gravity
  3209. the change in position of a child when its parent is so
  3210. resized is (-x, -y).  Note that StaticGravity still only
  3211. takes effect when the width or height of the window is
  3212. changed, not when the window is moved.
  3213.  
  3214. A bit_gravity of ForgetGravity indicates that the window's
  3215. contents are always discarded after a size change, even if a
  3216. backing_store or save_under has been requested.  The window
  3217. is tiled with its background and one or more exposure events
  3218. are generated. If no background is defined, the existing
  3219. screen contents are not altered.  Some X servers may also
  3220. ignore the specified bit_gravity and always generate expo-
  3221. sure events.
  3222.  
  3223. A win_gravity of UnmapGravity is like NorthWest (the window
  3224. is not moved), but the child is also unmapped when the
  3225. parent is resized, and an UnmapNotify event is generated.  X
  3226. generates GravityNotify notify events after generating Con-
  3227. figureNotify events.  A win_gravity of AntiGravity indicates
  3228. all pixels should move radically outward from the center of
  3229. the window._
  3230.  
  3231. The restack check (specifically, the computation for Bot-
  3232. tomIf, TopIf, and Opposite) is performed with respect to the
  3233. window's final size and position (as controlled by the other
  3234. arguments to the request), not its initial position.  It is
  3235. an error if a sibling is specified without a stack_mode.
  3236.  
  3237. If a sibling and a stack_mode are specified, the window is
  3238. restacked as follows:
  3239. __________________________
  3240. _ (If you believe this statement, there is a bridge for
  3241. sale.)
  3242.  
  3243.  
  3244.  
  3245.  
  3246.                      December 18, 1987
  3247.  
  3248.  
  3249.  
  3250.  
  3251.  
  3252.                            - 45 -
  3253.  
  3254.  
  3255. Above
  3256.              The window is placed just above the sibling.
  3257.  
  3258. Below
  3259.              The window is placed just below the sibling.
  3260.  
  3261. TopIf
  3262.              If the sibling occludes the window, the window is
  3263.              placed at the top of the stack.
  3264.  
  3265.  
  3266. BottomIf
  3267.              If the window occludes the sibling, the window is
  3268.              placed at the bottom of the stack.
  3269.  
  3270.  
  3271. Opposite
  3272.              If the sibling occludes the window, the window is
  3273.              placed at the top of the stack.  Otherwise, if the
  3274.              window occludes the sibling, the window is placed
  3275.              at the bottom of the stack.
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282. If a stack_mode is specified but no sibling is specified,
  3283. the window is restacked as follows:
  3284.  
  3285. Above
  3286.              The window is placed at the top of the stack.
  3287.  
  3288. Below
  3289.              The window is placed at the bottom of the stack.
  3290.  
  3291. TopIf
  3292.              If any sibling occludes the window, the window is
  3293.              placed at the top of the stack.
  3294.  
  3295.  
  3296. BottomIf
  3297.              If the window occludes any sibling, the window is
  3298.              placed at the bottom of the stack.
  3299.  
  3300.  
  3301. Opposite
  3302.              If any sibling occludes the window, the window is
  3303.              placed at the top of the stack. Otherwise, if the
  3304.              window occludes any sibling, the window is placed
  3305.              at the bottom of the stack.
  3306.  
  3307.  
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313. Use XConfigureWindow to reconfigure a window's size, posi-
  3314. tion, border, and stacking order.  The definition for this
  3315. function is:
  3316.  
  3317. XConfigureWindow(display, w, value_mask, values)
  3318.       Display *display;
  3319.       Window w;
  3320.       unsigned int value_mask;
  3321.       XWindowChanges *values;
  3322.  
  3323.  
  3324. display   Specifies the connection to the X server.
  3325.  
  3326. w         Specifies the window ID.  This is the window to be
  3327.           reconfigured.
  3328.  
  3329. value_maskSpecifies which values are to be set using infor-
  3330.           mation in the values structure.  This mask is the
  3331.           bitwise inclusive OR of the valid change window
  3332.           values bits.
  3333.  
  3334.  
  3335.  
  3336.  
  3337.  
  3338.                      December 18, 1987
  3339.  
  3340.  
  3341.  
  3342.  
  3343.  
  3344.                            - 46 -
  3345.  
  3346.  
  3347. values    Specifies a pointer to the structure XWin-
  3348.           dowChanges.
  3349.  
  3350. The XConfigureWindow function uses the values specified in
  3351. the XWindowChanges structure to reconfigure a window's size,
  3352. position, border, and stacking order.  The stacking order of
  3353. the window is controlled by the function's arguments.
  3354. Values not specified are taken from the existing geometry of
  3355. the window.
  3356.  
  3357. A BadMatch error is generated if a sibling is specified
  3358. without a stack_mode or if the window is not actually a
  3359. sibling.  Note that the computations for BottomIf, TopIf,
  3360. and Opposite are performed with respect to the window's
  3361. final geometry (as controlled by the other arguments passed
  3362. to XConfigureWindow), not its initial geometry.  Any
  3363. backing-store contents of the window, its inferiors, and
  3364. other newly visible windows are either discarded or changed
  3365. to reflect the current screen contents (implementation
  3366. dependent).
  3367.  
  3368. The errors that can be generated by XConfigureWindow are
  3369. BadWindow, BadMatch, and BadValue.
  3370.  
  3371.  
  3372. Use XMoveWindow to move a window without changing its size.
  3373. The definition for this function is:
  3374.  
  3375. XMoveWindow(display, w, x, y)
  3376.       Display *display;
  3377.       Window w;
  3378.       int x, y;
  3379.  
  3380.  
  3381. display   Specifies the connection to the X server.
  3382.  
  3383. w         Specifies the window ID.  This is the window to be
  3384.           moved.
  3385.  
  3386. x
  3387. y         Specify the x and y coordinates.  These coordi-
  3388.           nates define the new location of the top left
  3389.           pixel of the window's border or the window itself,
  3390.           if it has no border.
  3391.  
  3392. The XMoveWindow function moves the specified window to the
  3393. specified x and y coordinates.  This function does not
  3394. change the window's size, does not raise the window, and
  3395. does not change the mapping state of the window.  Moving a
  3396. mapped window may or may not lose its contents depending on:
  3397.  
  3398. o    If its tile mode is relative
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.                      December 18, 1987
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.                            - 47 -
  3411.  
  3412.  
  3413. o    If the window is obscured by nonchildren
  3414.  
  3415. If the contents of the window are lost, exposure events will
  3416. be generated for the window and any mapped subwindows.  Mov-
  3417. ing a mapped window will generate exposure events on any
  3418. formerly obscured  windows.
  3419.  
  3420. If the override_redirect attribute of the window is False
  3421. and some other client has selected SubstructureRedirectMask
  3422. on the parent, a ConfigureRequest event is generated, and no
  3423. further processing is performed. Otherwise, the window is
  3424. moved.
  3425.  
  3426. The error that can be generated by XMoveWindow is BadWindow.
  3427.  
  3428.  
  3429. Use XResizeWindow to change a window's size without changing
  3430. the upper left coordinate. The definition for XResizeWindow
  3431. is:
  3432.  
  3433. XResizeWindow(display, w, width, height)
  3434.       Display *display;
  3435.       Window w;
  3436.       unsigned int width, height;
  3437.  
  3438.  
  3439. display   Specifies the connection to the X server.
  3440.  
  3441. w         Specifies the window ID.
  3442.  
  3443. width
  3444. height    Specify the width and height.  These are the
  3445.           dimensions of the window after the call completes.
  3446.  
  3447. The XResizeWindow function changes the inside dimensions of
  3448. the specified window, not including its borders.  This func-
  3449. tion does not change the window's upper-left coordinate or
  3450. the origin and does not raise the window.  Changing the size
  3451. of a mapped window may lose its contents and generate an
  3452. Expose event.  If a mapped window is made smaller, exposure
  3453. events will be generated on windows that it formerly
  3454. obscured.
  3455.  
  3456. If the override_redirect attribute of the window is False
  3457. and some other client has selected SubstructureRedirectMask
  3458. on the parent, a ConfigureRequest event is generated, and no
  3459. further processing is performed.
  3460.  
  3461. The error that can be generated by XResizeWindow is BadWin-
  3462. dow.
  3463.  
  3464.  
  3465. Use XMoveResizeWindow to change the size and location of a
  3466. window. The definition for this function is:
  3467.  
  3468.  
  3469.  
  3470.                      December 18, 1987
  3471.  
  3472.  
  3473.  
  3474.  
  3475.  
  3476.                            - 48 -
  3477.  
  3478.  
  3479. XMoveResizeWindow(display, w, x, y, width, height)
  3480.       Display *display;
  3481.       Window w;
  3482.       int x, y;
  3483.       unsigned int width, height;
  3484.  
  3485.  
  3486. display   Specifies the connection to the X server.
  3487.  
  3488. w         Specifies the window ID.  This is the window to be
  3489.           reconfigured.
  3490.  
  3491. x
  3492. y         Specify the x and y coordinates.  These coordi-
  3493.           nates define the new position of the window rela-
  3494.           tive to its parent.
  3495.  
  3496. width
  3497. height    Specify the width and height.  These arguments
  3498.           define the interior size of the window.
  3499.  
  3500. The XMoveResizeWindow function changes the size and location
  3501. of the specified window without raising it.  Moving and
  3502. resizing a mapped window may generate an Expose event on the
  3503. window.  Depending on the new size and location parameters,
  3504. moving and resizing a window may generate exposure events on
  3505. windows that the window formerly obscured.
  3506.  
  3507. If the override_redirect attribute of the window is False
  3508. and some other client has selected SubstructureRedirectMask
  3509. on the parent, then a ConfigureRequest event is generated,
  3510. and no further processing is performed. Otherwise, the win-
  3511. dow size and location is changed.
  3512.  
  3513. The errors that can be generated by XMoveResizeWindow are
  3514. BadWindow, BadMatch, and BadValue.
  3515.  
  3516.  
  3517. Use XSetWindowBorderWidth to change the border width of a
  3518. window.  The definition for this function is:
  3519.  
  3520. XSetWindowBorderWidth(display, w, width)
  3521.       Display *display;
  3522.       Window w;
  3523.       unsigned int width;
  3524.  
  3525.  
  3526. display   Specifies the connection to the X server.
  3527.  
  3528. w         Specifies the window ID.
  3529.  
  3530. width     Specifies the width of the window border.
  3531.  
  3532. The XSetWindowBorderWidth function sets the specified
  3533.  
  3534.  
  3535.  
  3536.                      December 18, 1987
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.                            - 49 -
  3543.  
  3544.  
  3545. window's border width to the specified width.
  3546.  
  3547. The errors that can be generated by XSetWindowBorderWidth
  3548. are BadWindow and BadValue.
  3549.  
  3550. 3.8.  Changing Window Stacking Order
  3551.  
  3552. Xlib provides functions with which you can raise, lower,
  3553. circulate, or restack windows.
  3554.  
  3555.  
  3556. Use XRaiseWindow to raise a window so that no sibling window
  3557. obscures it.  The definition for this function is:
  3558.  
  3559. XRaiseWindow(display, w)
  3560.       Display *display;
  3561.       Window w;
  3562.  
  3563.  
  3564. display   Specifies the connection to the X server.
  3565.  
  3566. w         Specifies the window ID.
  3567.  
  3568. The XRaiseWindow function raises the specified window to the
  3569. top of the stack so that no sibling window obscures it.  If
  3570. the windows are regarded as overlapping sheets of paper
  3571. stacked on a desk, then raising a window is analogous to
  3572. moving the sheet to the top of the stack but leaving its x
  3573. and y location on the desk constant.  Raising a mapped win-
  3574. dow may generate exposure events for the window and any
  3575. mapped subwindows that were formerly obscured.
  3576.  
  3577. If the override_redirect attribute of the window is False
  3578. and some other client has selected SubstructureRedirectMask
  3579. on the parent, a ConfigureRequest event is generated, and no
  3580. processing is performed.  Otherwise, the window is raised.
  3581.  
  3582. The error that can be generated by XRaiseWindow is BadWin-
  3583. dow.
  3584.  
  3585.  
  3586. Use XLowerWindow to lower a window so that it does not
  3587. obscure any sibling windows. The definition for this func-
  3588. tion is:
  3589.  
  3590. XLowerWindow(display, w)
  3591.       Display *display;
  3592.       Window w;
  3593.  
  3594.  
  3595. display   Specifies the connection to the X server.
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.                      December 18, 1987
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.                            - 50 -
  3609.  
  3610.  
  3611. w         Specifies the window ID.
  3612.  
  3613. The XLowerWindow function lowers the specified window to the
  3614. bottom of the stack so that it does not obscure any sibling
  3615. windows.  If the windows are regarded as overlapping sheets
  3616. of paper stacked on a desk, then lowering a window is analo-
  3617. gous to moving the sheet to the bottom of the stack but
  3618. leaving its x and y location on the desk constant.  Lowering
  3619. a mapped window will generate exposure events on any windows
  3620. it formerly obscured.
  3621.  
  3622. If the override_redirect attribute of the window is False
  3623. and some other client has selected SubstructureRedirectMask
  3624. on the parent, a ConfigureRequest event is generated, and no
  3625. processing is performed. Otherwise, the window is lowered to
  3626. the bottom of the stack.
  3627.  
  3628. The error that can be generated by XLowerWindow is BadWin-
  3629. dow.
  3630.  
  3631.  
  3632. Use XCirculateSubwindows to circulate a subwindow up or
  3633. down.  The definition for this function is:
  3634.  
  3635. XCirculateSubwindows(display, w, direction)
  3636.       Display *display;
  3637.       Window w;
  3638.       int direction;
  3639.  
  3640.  
  3641. display   Specifies the connection to the X server.
  3642.  
  3643. w         Specifies the window ID.
  3644.  
  3645. direction Specifies the direction (up or down) that you want
  3646.           to circulate the window. You can pass one of these
  3647.           constants:  RaiseLowest or LowerHighest.
  3648.  
  3649. The XCirculateSubwindows function circulates the specified
  3650. subwindow in the specified direction:  RaiseLowest or
  3651. LowerHighest.  If some other client has selected Substruc-
  3652. tureRedirectMask on the window, a CirculateRequest event is
  3653. generated, and no further processing is performed.  Other-
  3654. wise, the processing described in the following paragraph is
  3655. performed, and if the window is actually restacked, the X
  3656. server generates a CirculateNotify event.
  3657.  
  3658. If you specify RaiseLowest, this function raises the lowest
  3659. mapped child (if any) that is occluded by another child to
  3660. the top of the stack.  If you specify LowerHighest, this
  3661. function lowers the highest mapped child (if any) that
  3662. occludes another child to the bottom of the stack.  Exposure
  3663. processing is performed on formerly obscured windows.
  3664.  
  3665.  
  3666.  
  3667.  
  3668.                      December 18, 1987
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.                            - 51 -
  3675.  
  3676.  
  3677. The errors that can be generated by XCirculateSubwindows are
  3678. BadWindow and BadValue.
  3679.  
  3680.  
  3681. Use XCirculateSubwindowsUp to raise the lowest mapped child
  3682. of an occluded window. The definition for this function is:
  3683.  
  3684. XCirculateSubwindowsUp(display, w)
  3685.       Display *display;
  3686.       Window w;
  3687.  
  3688.  
  3689. display   Specifies the connection to the X server.
  3690.  
  3691. w         Specifies the window ID.
  3692.  
  3693. The XCirculateSubwindowsUp function raises the lowest mapped
  3694. child of the specified window that is partially or com-
  3695. pletely occluded by another child.  Completely unobscured
  3696. children are not affected.  This is a convenience routine
  3697. equivalent to XCirculateWindow (display, window,
  3698. RaiseLowest).
  3699.  
  3700. The error that can be generated by XCirculateSubwindowsUp is
  3701. BadWindow.
  3702.  
  3703.  
  3704. Use XCirculateSubwindowsDown to lower the highest mapped
  3705. child of a window that partially or completely occludes
  3706. another child. The definition for this function is:
  3707.  
  3708. XCirculateSubwindowsDown(display, w)
  3709.       Display *display;
  3710.       Window w;
  3711.  
  3712.  
  3713. display   Specifies the connection to the X server.
  3714.  
  3715. w         Specifies the window ID.
  3716.  
  3717. The XCirculateSubwindowsDown function lowers the highest
  3718. mapped child of the specified window that partially or com-
  3719. pletely occludes another child.  Completely unobscured chil-
  3720. dren are not affected.  This is a convenience routine
  3721. equivalent to XCirculateWindow (display, window,
  3722. LowerHighest).
  3723.  
  3724. The error that can be generated by XCirculateSubwindowsDown
  3725. is BadWindow.
  3726.  
  3727.  
  3728. Use XRestackWindows to restack a set of windows from top to
  3729. bottom. The definition for this function is:
  3730.  
  3731.  
  3732.  
  3733.  
  3734.                      December 18, 1987
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.                            - 52 -
  3741.  
  3742.  
  3743. XRestackWindows(display, windows, nwindows);
  3744.       Display *display;
  3745.       Window windows[];
  3746.       int nwindows;
  3747.  
  3748.  
  3749. display   Specifies the connection to the X server.
  3750.  
  3751. windows   Specifies an array containing the windows to be
  3752.           restacked.  All the windows must have the same
  3753.           parent.
  3754.  
  3755. nwindows  Specifies the number of windows to be restacked.
  3756.  
  3757. The XRestackWindows function restacks the windows in the
  3758. order specified, from top to bottom.  The stacking order of
  3759. the first window in the windows array will be unaffected,
  3760. but the other windows in the array will be stacked under-
  3761. neath the first window in the order of the array.  The
  3762. stacking order of the other windows is not affected.
  3763.  
  3764. If the override_redirect attribute of a window is False and
  3765. some other client has selected SubstructureRedirectMask on
  3766. the parent, ConfigureRequest events are generated for each
  3767. window whose override_redirect is not set, and no further
  3768. processing is performed.  Otherwise, the windows will be
  3769. restacked in top to bottom order.
  3770.  
  3771. The error that can be generated by XRestackWindows is
  3772. BadWindow.
  3773.  
  3774. 3.9.  Changing Window Attributes
  3775.  
  3776. Xlib provides functions with which you can set window attri-
  3777. butes.  XChangeWindowAttributes is the more general function
  3778. that allows you to set one or more window attributes pro-
  3779. vided by the XSetWindowAttributes structure.  See Section
  3780. 3.2 for descriptions of these window attributes.  The other
  3781. functions described in this section allow you to set one
  3782. specific window attribute, such as a window's background.
  3783.  
  3784. Use XChangeWindowAttributes to change one or more window
  3785. attributes.  The definition for this function is:
  3786.  
  3787. XChangeWindowAttributes(display, w, valuemask, attributes)
  3788.       Display *display;
  3789.       Window w;
  3790.       unsigned long valuemask;
  3791.       XSetWindowAttributes *attributes;
  3792.  
  3793.  
  3794. display   Specifies the connection to the X server.
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.                      December 18, 1987
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.                            - 53 -
  3807.  
  3808.  
  3809. w         Specifies the window ID.
  3810.  
  3811. valuemask Specifies which window attributes are defined in
  3812.           the attributes argument.  This mask is the bitwise
  3813.           inclusive OR of the valid attribute mask bits.  If
  3814.           valuemask is zero (0), the rest is ignored, and
  3815.           the attributes are not referenced.  The values and
  3816.           restrictions are the same as for XCreateSimpleWin-
  3817.           dow and XCreateWindow.
  3818.  
  3819.  
  3820. attributesAttributes of the window to be set at creation
  3821.           time should be set in this structure.  The
  3822.           valuemask should have the appropriate bits set to
  3823.           indicate which attributes have been set in the
  3824.           structure.
  3825.  
  3826. Depending on the valuemask, the XChangeWindowAttributes
  3827. function uses the window attributes in the XSetWindowAttri-
  3828. butes structure to change the specified window attributes.
  3829. Changing the background does not cause the window contents
  3830. to be changed.  Use XClearWindow to repaint the window and
  3831. its background.  (See Section 6.2 for further information.)
  3832. Setting the border or changing the background such that the
  3833. border tile origin changes causes the border to be
  3834. repainted.  Changing the background of a root window to None
  3835. or ParentRelative restores the default background pixmap.
  3836. Changing the border of a root window to CopyFromParent
  3837. restores the default border pixmap.  Changing the
  3838. win_gravity does not affect the current position of the win-
  3839. dow.  Either changing the backing_store of an obscured win-
  3840. dow to WhenMapped or Always, or changing the backing_planes,
  3841. backing_pixel, or save_under of a mapped window may have no
  3842. immediate effect.
  3843.  
  3844. Multiple clients can select input on the same window. If
  3845. this is the case, their event masks are maintained
  3846. separately.  When an event is generated, it will be reported
  3847. to all interested clients. However, at most, one client at a
  3848. time can select for SubstructureRedirectMask, Resiz-
  3849. eRedirectMask, and ButtonPressMask.  If a client attempts to
  3850. select any of these event masks and some other client has
  3851. already selected it, the X server generates a BadAccess
  3852. error.  There is only one do_not_propagate_mask for a win-
  3853. dow, not one per client.
  3854.  
  3855. Changing the color map of a window (that is, defining a new
  3856. map, not changing the contents of the existing map) gen-
  3857. erates a ColormapNotify event. Changing the color map of a
  3858. visible window may have no immediate effect on the screen
  3859. because the map may not be installed.  See XInstallColormap
  3860. in Chapter 7.  Changing the cursor of a root window to None
  3861. restores the default cursor.  Whenever possible, you are
  3862. encouraged to share color maps.
  3863.  
  3864.  
  3865.  
  3866.                      December 18, 1987
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.                            - 54 -
  3873.  
  3874.  
  3875. The other event errors that can be generated by XChangeWin-
  3876. dowAttributes are BadWindow, BadPixmap, BadColor, BadCursor,
  3877. BadMatch, BadAccess, and BadValue.
  3878.  
  3879.  
  3880. Use XSetWindowBackground to set the background of a speci-
  3881. fied window to the specified pixel. The definition for this
  3882. function is:
  3883.  
  3884.  
  3885. XSetWindowBackground(display, w, background_pixel)
  3886.       Display *display;
  3887.       Window w;
  3888.       unsigned long background_pixel;
  3889.  
  3890.  
  3891. display   Specifies the connection to the X server.
  3892.  
  3893. w         Specifies the window ID.
  3894.  
  3895. background_pixelSpecifies the pixel of the background.  This
  3896.           pixel value determines which entry in the colormap
  3897.           is used.
  3898.  
  3899. The XSetWindowBackground function sets the background pixel
  3900. of the window to the pixel value you specify.  Changing the
  3901. background does not cause the window contents to be changed.
  3902. XSetWindowBackground uses a pixmap of undefined size filled
  3903. with the color associated with the pixel value you passed to
  3904. the background_pixel argument.  This can not be performed on
  3905. an InputOnly window.  An error will result if you try to
  3906. change the background of an InputOnly window.
  3907.  
  3908. The errors that can be generated by XSetWindowBackground are
  3909. BadWindow and BadMatch.
  3910.  
  3911.  
  3912.  
  3913. Use XSetWindowBackgroundPixmap to set the background of a
  3914. specified window to the specified pixmap.  The definition
  3915. for XSetWindowBackgroundPixmap is:
  3916.  
  3917.  
  3918. XSetWindowBackgroundPixmap(display, w, background_pixmap)
  3919.       Display *display;
  3920.       Window w;
  3921.       Pixmap background_pixmap;
  3922.  
  3923.  
  3924. display   Specifies the connection to the X server.
  3925.  
  3926. w         Specifies the window ID.
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.                      December 18, 1987
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.                            - 55 -
  3939.  
  3940.  
  3941. background_pixmapSpecifies the background pixmap.  If a Pix-
  3942.           map ID is specified, the background is painted
  3943.           with this pixmap.  If None, no background is
  3944.           painted.  If ParentRelative, the parent's pixmap
  3945.           is used.
  3946.  
  3947. The XSetWindowBackgroundPixmap function sets the background
  3948. pixmap of the window to the pixmap you specify.  If no back-
  3949. ground Pixmap is specified, the background pixmap of the
  3950. window's parent is used.  On the root window, the default
  3951. background will be restored.  The background Pixmap can
  3952. immediately be freed if no further explicit references to it
  3953. are to be made.  This can not be performed on an InputOnly
  3954. window.  An error will result if you try to change the back-
  3955. ground of an InputOnly window.
  3956.  
  3957. The errors that can be generated by XSetWindowBackgroundPix-
  3958. map are BadWindow, BadPixmap, BadColor, and BadMatch.
  3959.  
  3960.                             Note
  3961.  
  3962.      XSetWindowBackground and XSetWindowBackgroundPix-
  3963.      map do not change the current contents of the win-
  3964.      dow, and you may wish to clear and repaint the
  3965.      screen after these functions because they will not
  3966.      repaint the background you just set.
  3967.  
  3968.  
  3969.  
  3970. Use XSetWindowBorder to change and repaint a window's border
  3971. to the specified pixel. The definition for this function is:
  3972.  
  3973. XSetWindowBorder(display, w, border_pixel)
  3974.       Display *display;
  3975.       Window w;
  3976.       unsigned long border_pixel;
  3977.  
  3978.  
  3979. display   Specifies the connection to the X server.
  3980.  
  3981. w         Specifies the window ID.
  3982.  
  3983. border_pixelSpecifies the entry in the color map.
  3984.  
  3985. The XSetWindowBorder function sets the border pixel of the
  3986. window to the pixel value you specify.  It uses this value
  3987. as an entry into the color map to determine which color is
  3988. to be used to paint the border.  This can not be performed
  3989. on an InputOnly window.  It will cause an error to perform
  3990. this on an InputOnly window.
  3991.  
  3992. The errors that can be generated by XSetWindowBorder are
  3993. BadWindow, BadPixmap, BadMatch, and BadValue.
  3994.  
  3995.  
  3996.  
  3997.  
  3998.                      December 18, 1987
  3999.  
  4000.  
  4001.  
  4002.  
  4003.  
  4004.                            - 56 -
  4005.  
  4006.  
  4007. Use XSetWindowBorderPixmap to change and repaint a window's
  4008. border tile. The definition for this function is:
  4009.  
  4010. XSetWindowBorderPixmap(display, w, border_pixmap)
  4011.       Display *display;
  4012.       Window w;
  4013.       Pixmap border_pixmap;
  4014.  
  4015.  
  4016. display   Specifies the connection to the X server.
  4017.  
  4018. w         Specifies the window ID.
  4019.  
  4020. border_pixmapSpecifies the border pixmap.  If you specify a
  4021.           pixmap ID, the associated pixmap is used for the
  4022.           border.  If CopyFromParent is specified, a copy of
  4023.           the parent window's border pixmap is used.
  4024.  
  4025. The XSetWindowBorderPixmap function sets the border pixmap
  4026. of the window to the pixmap you specify.  It uses this entry
  4027. for the border.  The border Pixmap can be freed immediately
  4028. if no further explicit references to it are to be made.
  4029. This can not be performed on an InputOnly window.  It will
  4030. cause an error to perform this on an InputOnly window.
  4031.  
  4032. The errors that can be generated by XSetWindowBorderPixmap
  4033. are BadWindow, BadPixmap, BadMatch, and BadValue.
  4034.  
  4035. 3.10.  Translating Window Coordinates
  4036.  
  4037. Applications, mostly window managers, often need to perform
  4038. a coordinate transformation from the coordinate space of one
  4039. window to another window or need to determine which subwin-
  4040. dow a coordinate lies in.  XTranslateCoordinates fulfills
  4041. these needs and avoids any race conditions by asking the X
  4042. server to perform this operation.  The definition for this
  4043. function is:
  4044.  
  4045. int XTranslateCoordinates(display, src_w, dest_w, src_x, src_y, dest_x_return,
  4046.                             dest_y_return, child_return)
  4047.       Display *display;
  4048.       Window src_w, dest_w;
  4049.       int src_x, src_y;
  4050.       int *dest_x_return, *dest_y_return;
  4051.       Window *child_return;
  4052.  
  4053.  
  4054. display   Specifies the connection to the X server.
  4055.  
  4056. src_w     Specifies the window ID of the source window.
  4057.  
  4058. dest_w    Specifies the window ID of the destination window.
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.                      December 18, 1987
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.                            - 57 -
  4071.  
  4072.  
  4073. src_x
  4074. src_y     Specify the x and y coordinates within the source
  4075.           window.
  4076.  
  4077. dest_x_return
  4078. dest_y_returnReturns the x and y coordinates within the des-
  4079.           tination window.
  4080.  
  4081. child_returnReturns the child if the coordinates are con-
  4082.           tained in a mapped child of the destination win-
  4083.           dow.
  4084.  
  4085. The XTranslateCoordinates function takes the src_x and src_y
  4086. coordinates within the source window relative to the source
  4087. window's origin and returns these coordinates to
  4088. dest_x_return and dest_y_return relative to the destination
  4089. window's origin.  If XTranslateCoordinates returns zero (0),
  4090. src_w and dest_w are on different screens, and dest_x_return
  4091. and dest_y_return are zero (0).  If the coordinates are con-
  4092. tained in a mapped child of dest_w, that child is returned
  4093. to the child argument.
  4094.  
  4095. The error that can be generated by XTranslateCoordinates is
  4096. BadWindow.
  4097.  
  4098.  
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.  
  4114.  
  4115.  
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.  
  4128.  
  4129.  
  4130.                      December 18, 1987
  4131.  
  4132.  
  4133.  
  4134.  
  4135.  
  4136.                            - 58 -
  4137.  
  4138.  
  4139.  
  4140.  
  4141.                          Chapter 4
  4142.  
  4143.                 Window Information Functions
  4144.  
  4145.  
  4146.  
  4147. Chapter 4 - Window Information Functions After you connect
  4148. the display to the X server and create a window, you can use
  4149. the Xlib window information functions to:
  4150.  
  4151. o    Obtain information about a window
  4152.  
  4153. o    Manipulate property lists
  4154.  
  4155. o    Obtain and change window properties
  4156.  
  4157. o    Manipulate window selection
  4158.  
  4159. 4.1.  Obtaining Window Information
  4160.  
  4161. Xlib provides functions with which you can obtain informa-
  4162. tion about the window tree, the current attributes of a win-
  4163. dow, its current geometry, or the current pointer coordi-
  4164. nates.  Because they are most frequently used by window
  4165. managers, these functions all return a status to indicate
  4166. whether the window still exists.
  4167.  
  4168.  
  4169. Use XQueryTree to obtain a list of children, the parent, and
  4170. number of children for a specified window. The definition
  4171. for this function is:
  4172.  
  4173. Status XQueryTree(display, w, root_return, parent_return, children_return, nchildren_return)
  4174.       Display *display;
  4175.       Window w;
  4176.       Window *root_return;
  4177.       Window *parent_return;
  4178.       Window **children_return;
  4179.       unsigned int *nchildren_return;
  4180.  
  4181.  
  4182. display   Specifies the connection to the X server.
  4183.  
  4184. w         Specifies the window ID.  For this window, you
  4185.           obtain the list of its children, its root, its
  4186.           parent, and the number of children.
  4187.  
  4188. root_returnReturns the root window ID for the specified win-
  4189.           dow.
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.                      December 18, 1987
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.                            - 59 -
  4203.  
  4204.  
  4205. parent_returnReturns the parent window ID for the specified
  4206.           window.
  4207.  
  4208. children_returnReturns a pointer to the list of children for
  4209.           the specified window.
  4210.  
  4211. nchildren_returnReturns the number of children for the
  4212.           specified window.
  4213.  
  4214. The XQueryTree function returns the root ID, the parent win-
  4215. dow ID, a pointer to the list of children windows, and the
  4216. number of children in the list for the specified window.
  4217. Use XFree to free this list when it is no longer needed.
  4218. (See Section 2.4 for further information.)  The children are
  4219. listed in current stacking order, from bottom-most (first)
  4220. to top-most (last).  XQueryTree returns zero (0) if it fails
  4221. and nonzero if it succeeds.
  4222.  
  4223. The error that can be generated by XQueryTree is BadWindow.
  4224.  
  4225.  
  4226. Use XGetWindowAttributes to obtain the current attributes
  4227. for a specified window. The definition for this function is:
  4228.  
  4229. Status XGetWindowAttributes(display, w, window_attributes_return)
  4230.       Display *display;
  4231.       Window w;
  4232.       XWindowAttributes *window_attributes_return;
  4233.  
  4234.  
  4235. display   Specifies the connection to the X server.
  4236.  
  4237. w         Specifies the window ID.  This is the window whose
  4238.           current attributes you want to obtain.
  4239.  
  4240. window_attributes_returnRturns the specified window's attri-
  4241.           butes in the XWindowAttributes structure.
  4242.  
  4243. The XGetWindowAttributes function returns the current attri-
  4244. butes for the specified window to an XWindowAttributes
  4245. structure.  This structure is defined as follows:
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254.  
  4255.  
  4256.  
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.                      December 18, 1987
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.                            - 60 -
  4269.  
  4270.  
  4271.  
  4272. typedef struct {
  4273.      int x, y;                /* location of window */
  4274.      int width, height;       /* width and height of window */
  4275.      int border_width;        /* border width of window */
  4276.      int depth;               /* depth of window */
  4277.      Visual *visual;          /* the associated visual structure */
  4278.      Window root;             /* root of screen containing window */
  4279.      int class;               /* InputOutput, InputOnly*/
  4280.      int bit_gravity;         /* one of bit gravity values */
  4281.      int win_gravity;         /* one of the window gravity values */
  4282.      int backing_store;       /* NotUseful, WhenMapped, Always */
  4283.      unsigned long backing_planes;/* planes to be preserved if possible */
  4284.      unsigned long backing_pixel;/* value to be used when restoring planes */
  4285.      Bool save_under;         /* boolean, should bits under be saved? */
  4286.      Colormap colormap;       /* color map to be associated with window */
  4287.      Bool map_installed;      /* boolean, is color map currently installed*/
  4288.      int map_state;           /* IsUnmapped, IsUnviewable, IsViewable */
  4289.      long all_event_masks;    /* set of events all people have interest in*/
  4290.      long your_event_mask;    /* my event mask */
  4291.      long do_not_propagate_mask;/* set of events that should not propagate */
  4292.      Bool override_redirect;  /* boolean value for override-redirect */
  4293.      Screen *screen;          /* back pointer to correct screen */
  4294. } XWindowAttributes;
  4295.  
  4296.  
  4297. The x and y members are set to the coordinates that define
  4298. the location of the drawable.  If the drawable is a window,
  4299. these coordinates specify the upper left outer corner rela-
  4300. tive to the parent window's origin.  If the drawable is a
  4301. pixmap, these members are set to zero (0).  The width and
  4302. height members are set to the drawable's dimensions.  For a
  4303. window, these dimensions specify the inside size of the win-
  4304. dow, not including the border.
  4305.  
  4306. The border_width member is set to the window's border width
  4307. in pixels.  If the drawable is a pixmap, this member is set
  4308. to zero (0).  The depth member is set to the depth of the
  4309. pixmap (that is, bits per pixel for the object).  The depth
  4310. must be supported by the root of the specified drawable.
  4311.  
  4312. The visual member is a pointer to the screen's associated
  4313. Visual structure.  The root member is set to the root ID of
  4314. the screen containing the window.  The class member is set
  4315. to the window's class and can be one of the constants Inpu-
  4316. tOutput or InputOnly.
  4317.  
  4318. The bit_gravity member is set to the window's bit gravity
  4319. and can be one of these constants:
  4320.  
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.                      December 18, 1987
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.                            - 61 -
  4335.  
  4336.  
  4337. ForgetGravity  EastGravity
  4338. NorthWestGravitySouthWestGravity
  4339. NorthGravity   SouthGravity
  4340. NorthEastGravitySouthEastGravity
  4341. WestGravity    StaticGravity
  4342. CenterGravity
  4343.  
  4344.  
  4345. See the Configuring Windows section in Chapter 3 for addi-
  4346. tional information on bit gravity.
  4347.  
  4348. The win_gravity member is set to the window's window gravity
  4349. and can be one of these constants:
  4350.  
  4351. UnmapGravity   EastGravity
  4352. NorthWestGravitySouthWestGravity
  4353. NorthGravity   SouthGravity
  4354. NorthEastGravitySouthEastGravity
  4355. WestGravity    StaticGravity
  4356. CenterGravity
  4357.  
  4358.  
  4359. The backing_store member is set to indicate how the X server
  4360. should maintain the contents of a window.  It can be set to
  4361. one of the constants WhenMapped, Always, or NotUseful.  The
  4362. backing_planes member is set to indicate (with one bits)
  4363. which bit planes of the window hold dynamic data that must
  4364. be preserved in backing_stores and during save_unders.  The
  4365. backing_pixel member is set to indicate what values to use
  4366. when restoring planes from a partial backing store.
  4367.  
  4368. The save_under member is set to one of the constants True or
  4369. False.  The colormap member is set to the color map for the
  4370. specified window and can be a colormap ID or the constant
  4371. None.  The map_installed member is set to indicate whether
  4372. the color map is currently installed.  It can be one of the
  4373. constants True or False.  The map_state member is set to
  4374. indicate the state of the window and can be one of the con-
  4375. stants IsUnmapped, IsUnviewable, or IsViewable.  This member
  4376. gets set to IsUnviewable if the window is mapped but some
  4377. ancestor is unmapped.
  4378.  
  4379. The all_event_masks member is set to the bitwise inclusive
  4380. OR of all event masks selected on the window by interested
  4381. clients.  The your_event_mask member is set to the bitwise
  4382. inclusive OR of all event masks selected by the querying
  4383. client.  The do_not_propagate_mask member is set to the bit-
  4384. wise inclusive OR of the set of events that should not pro-
  4385. pagate.  See Section 8.3 for a discussion of events and the
  4386. event mask.
  4387.  
  4388. The override_redirect member is set to indicate whether this
  4389. window overrides structure control facilities.  It can be
  4390. one of the constants True or False.  Window manager clients
  4391.  
  4392.  
  4393.  
  4394.                      December 18, 1987
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.                            - 62 -
  4401.  
  4402.  
  4403. usually should ignore the window if this member is True.
  4404. Transient windows should mark which windows they are associ-
  4405. ated with.  See Section 9.1.9 for further information.
  4406.  
  4407. The screen member is set to a screen pointer that gives you
  4408. a back pointer to the correct screen.  This makes it easier
  4409. to obtain the screen information without having to loop over
  4410. the root window fields to see which matches.
  4411.  
  4412. The error that can be generated by XGetWindowAttributes is
  4413. BadWindow.
  4414.  
  4415.  
  4416. Use XGetGeometry to obtain the current geometry of the
  4417. specified drawable. The definition for this function is:
  4418.  
  4419. Status XGetGeometry(display, d, root_return, x_return, y_return, width_return,
  4420.                       height_return, border_width_return, depth_return)
  4421.         Display *display;
  4422.         Drawable d;
  4423.         Window *root_return;
  4424.         int *x_return, *y_return;
  4425.         unsigned int *width_return, *height_return;
  4426.         unsigned int *border_width_return;
  4427.         unsigned int *depth_return;
  4428.  
  4429.  
  4430. display   Specifies the connection to the X server.
  4431.  
  4432. d         Specifies the drawable. The drawable can be either
  4433.           a window or a pixmap.
  4434.  
  4435. root_returnReturns the root window ID for the specified win-
  4436.           dow.
  4437.  
  4438. x_return
  4439.  
  4440. y_return  Returns the x and y coordinates of the drawable.
  4441.           These coordinates define the location of the draw-
  4442.           able.  For a window, these coordinates specify the
  4443.           upper left outer corner relative to its parent's
  4444.           origin.  For pixmaps, these coordinates are always
  4445.           zero (0).
  4446.  
  4447. width_return
  4448. height_returnReturns the drawable's dimensions (width and
  4449.           height).  For a window, these dimensions specify
  4450.           the inside size, not including the border.
  4451.  
  4452. border_width_returnReturns the border width in pixels. The
  4453.           function returns the border width only if the
  4454.           drawable is a window.  It returns zero (0) if the
  4455.           drawable is a pixmap.
  4456.  
  4457.  
  4458.  
  4459.  
  4460.                      December 18, 1987
  4461.  
  4462.  
  4463.  
  4464.  
  4465.  
  4466.                            - 63 -
  4467.  
  4468.  
  4469. depth_returnReturns the depth of the pixmap (bits per pixel
  4470.           for the object).
  4471.  
  4472. The XGetGeometry function returns the root ID and the
  4473. current geometry of the drawable.  The geometry of the draw-
  4474. able includes the x and y coordinates, width and height,
  4475. border width, and depth.  These are described in the argu-
  4476. ment list.  It is legal to pass to this function a window
  4477. whose class is InputOnly.
  4478.  
  4479. The error that can be generated by XGetGeometry is BadDraw-
  4480. able.
  4481.  
  4482.  
  4483. Use XQueryPointer to obtain the root window the pointer is
  4484. currently on and the pointer coordinates relative to the
  4485. root's origin.  The definition for this function is:
  4486.  
  4487. Bool XQueryPointer(display, w, root_return, child_return, root_x_return, root_y_return,
  4488.                      win_x_return, win_y_return, mask_return)
  4489.       Display *display;
  4490.       Window w;
  4491.       Window *root_return, *child_return;
  4492.       int *root_x_return, *root_y_return;
  4493.       int *win_x_return, *win_y_return;
  4494.       unsigned int *mask_return;
  4495.  
  4496.  
  4497. display   Specifies the connection to the X server.
  4498.  
  4499. w         Specifies the window ID.
  4500.  
  4501. root_returnReturns the root window ID for the specified win-
  4502.           dow.  This root ID identifies the root window the
  4503.           pointer is currently on.
  4504.  
  4505. child_returnReturns the child window ID that the pointer is
  4506.           located in, if any.
  4507.  
  4508. root_x_return
  4509. root_y_returnReturns the pointer coordinates relative to the
  4510.           root window's origin.
  4511.  
  4512. win_x_return
  4513. win_y_returnReturns the pointer coordinates relative to the
  4514.           specified window.
  4515.  
  4516. mask_returnReturns the current state of the modifier keys
  4517.           and pointer buttons.
  4518.  
  4519. The XQueryPointer function returns the root window the
  4520. pointer is currently on and the pointer coordinates relative
  4521. to the root window's origin.  If XQueryPointer returns
  4522. False, the pointer is not on the same screen as the window
  4523.  
  4524.  
  4525.  
  4526.                      December 18, 1987
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.                            - 64 -
  4533.  
  4534.  
  4535. associated with the window you passed to the w argument.  In
  4536. this case, the function returns the constant None to
  4537. child_return and zero (0) to win_x_return and win_y_return.
  4538. If XQueryPointer returns True, the pointer coordinates
  4539. returned to win_x_return and win_y_return are relative to
  4540. the origin of the window identified by the w argument.  In
  4541. this case, the function returns the ID of the child contain-
  4542. ing the pointer, if any.
  4543.  
  4544. The state of the keyboard buttons and the modifier keys are
  4545. returned in the mask_return argument.  Depending on the
  4546. current state of the mouse buttons and the modifier keys,
  4547. XQueryPointer can set this argument to the bitwise inclusive
  4548. OR of one or more of the button or modifier key bitmasks:
  4549. Button1Mask, Button2Mask, Button3Mask, Button4Mask,
  4550. Button5Mask, ShiftMask, LockMask, ControlMask, Mod1Mask,
  4551. Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.
  4552.  
  4553. The error that can be generated by XQueryPointer is BadWin-
  4554. dow.
  4555.  
  4556. 4.2.  Properties and Atoms
  4557.  
  4558. A property is a collection of named typed data.  The type of
  4559. a property is defined by other properties, which allows for
  4560. arbitrary extension in this type scheme.  Data of more than
  4561. one type may be associated with a single property. An Atom
  4562. is just a nickname for a property, so that the protocol does
  4563. not have to send arbitrary length property names back and
  4564. forth.
  4565.  
  4566. A property is also stored in one of several possible for-
  4567. mats.  The X server can store the information as 8-bit quan-
  4568. tities, 16-bit quantities, or 32-bit quantities.  This per-
  4569. mits the X server to present the data in the byte order that
  4570. the client expects.
  4571.  
  4572.                             Note
  4573.  
  4574.      If you define further properties of complex type,
  4575.      you must encode and decode them yourself into one
  4576.      of the possible formats.
  4577.  
  4578.  
  4579. The window system has a set of predefined properties (for
  4580. example, the name of a window, size hints, and so on), and
  4581. users can define any other arbitrary information and can
  4582. associate them with windows.  Each property has a name,
  4583. which is an ISO Latin-1 string.  For each named property
  4584. there is a unique identifier (atom) associated with it. A
  4585. property also has a type, for example, string or integer.
  4586. These types are also indicated using atoms, so arbitrary new
  4587. types can be defined.
  4588.  
  4589.  
  4590.  
  4591.  
  4592.                      December 18, 1987
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.                            - 65 -
  4599.  
  4600.  
  4601. Certain properties are predefined in the server for commonly
  4602. used functions.  The atoms for these properties are defined
  4603. in <X11/Xatom.h>.  To avoid name clashes with user symbols,
  4604. the #define name for each atom has the ``XA_'' prefix added.
  4605. See Section 4.3 for definitions of these properties.  See
  4606. Chapter 9 for an explanation of the functions that let you
  4607. get and set much of the information stored in these prede-
  4608. fined properties.
  4609.  
  4610. You can use this mechanism to communicate other information
  4611. between applications.  The functions described in this sec-
  4612. tion let you define new properties and get the unique Atom
  4613. IDs in your applications.
  4614.  
  4615. Atoms occur in five distinct name spaces within the proto-
  4616. col.
  4617.  
  4618. o    Selections
  4619.  
  4620. o    Property names
  4621.  
  4622. o    Property types
  4623.  
  4624. o    Font properties
  4625.  
  4626. o    Type of a ClientMessage event (none are built into the
  4627.      X server)
  4628.  
  4629. Any particular atom can have some client interpretation
  4630. within each of the name spaces.
  4631.  
  4632. The built-in selection properties, which name properties,
  4633. are:
  4634.  
  4635. PRIMARY
  4636. SECONDARY
  4637.  
  4638.  
  4639. The built-in property names are:
  4640.  
  4641. CUT_BUFFER0            RGB_GREEN_MAP
  4642. CUT_BUFFER1            RGB_RED_MAP
  4643. CUT_BUFFER2            RESOURCE_MANAGER
  4644. CUT_BUFFER3            WM_CLASS
  4645. CUT_BUFFER4            WM_CLIENT_MACHINE
  4646. CUT_BUFFER5            WM_COMMAND
  4647. CUT_BUFFER6            WM_HINTS
  4648. CUT_BUFFER7            WM_ICON_NAME
  4649. RGB_BEST_MAP           WM_ICON_SIZE
  4650. RGB_BLUE_MAP           WM_NAME
  4651. RGB_DEFAULT_MAP        WM_NORMAL_HINTS
  4652. RGB_GRAY_MAP           WM_ZOOM_HINTS
  4653.  
  4654.  
  4655.  
  4656.  
  4657.                      December 18, 1987
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.                            - 66 -
  4664.  
  4665.  
  4666.                        WM_TRANSIENT_FOR
  4667.  
  4668.  
  4669. The built-in property types are:
  4670.  
  4671.  
  4672. ARC                    POINT
  4673. ATOM                   RGB_COLOR_MAP
  4674. BITMAP                 RECTANGLE
  4675. CARDINAL               STRING
  4676. COLORMAP               VISUALID
  4677. CURSOR                 WINDOW
  4678. DRAWABLE               WM_HINTS
  4679. FONT                   WM_SIZE_HINTS
  4680. INTEGER
  4681. PIXMAP
  4682.  
  4683.  
  4684. The built-in font property types are:
  4685.  
  4686. MIN_SPACE              STRIKEOUT_DESCENT
  4687. NORM_SPACE             STRIKEOUT_ASCENT
  4688. MAX_SPACE              ITALIC_ANGLE
  4689. END_SPACE              X_HEIGHT
  4690. SUPERSCRIPT_X          QUAD_WIDTH
  4691. SUPERSCRIPT_Y          WEIGHT
  4692. SUBSCRIPT_X            POINT_SIZE
  4693. SUBSCRIPT_Y            RESOLUTION
  4694. UNDERLINE_POSITION     COPYRIGHT
  4695. UNDERLINE_THICKNESS    NOTICE
  4696. FONT_NAME              FAMILY_NAME
  4697. FULL_NAME              CAP_HEIGHT
  4698.  
  4699.  
  4700.                             Note
  4701.  
  4702.      See Chapter 6 for further information about font
  4703.      property atoms.
  4704.  
  4705.  
  4706.  
  4707. Use XInternAtom to return an atom for a specified name. The
  4708. definition for this function is:
  4709.  
  4710. Atom XInternAtom(display, atom_name, only_if_exists)
  4711.       Display *display;
  4712.       char *atom_name;
  4713.       Bool only_if_exists;
  4714.  
  4715.  
  4716.  
  4717.  
  4718.  
  4719.  
  4720.                      December 18, 1987
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726.                            - 67 -
  4727.  
  4728.  
  4729. display   Specifies the connection to the X server.
  4730.  
  4731. atom_name Specifies the name associated with the atom you
  4732.           want returned.
  4733.  
  4734. only_if_existsSpecifies a boolean value that indicates
  4735.           whether XInternAtom creates the atom.  You can
  4736.           pass one of the constants True or False.
  4737.  
  4738. The XInternAtom function returns the atom identifier associ-
  4739. ated with the string you passed to the atom_name argument.
  4740. XInternAtom returns the atom for the specified atom_name if
  4741. only_if_exists is True.  If only_if_exists is False, the
  4742. atom is created if it does not exist.  Therefore, XInternA-
  4743. tom can return None.  You should use a null-terminated ISO
  4744. Latin-1 string for atom_name.  Case matters: the strings
  4745. "thing", "Thing", and "thinG" all designate different atoms.
  4746. The atom will remain defined even after the client who
  4747. defined it has gone away. It will become undefined only when
  4748. the last connection to the X server closes.
  4749.  
  4750. The errors that can be generated by XInternAtom are BadAlloc
  4751. and BadValue.
  4752.  
  4753.  
  4754. Use XGetAtomName to return a name for the specified atom
  4755. identifier.  The definition for this function is:
  4756.  
  4757. char *XGetAtomName(display, atom)
  4758.       Display *display;
  4759.       Atom atom;
  4760.  
  4761.  
  4762. display   Specifies the connection to the X server.
  4763.  
  4764. atom      Specifies the atom associated with the string name
  4765.           you want returned.
  4766.  
  4767. The XGetAtomName function returns the name associated with
  4768. the atom identifier you passed to the atom argument.  You
  4769. previously obtained the atom identifier by calling XInternA-
  4770. tom.
  4771.  
  4772. The error that can be generated by XGetAtomName is BadAtom.
  4773.  
  4774. 4.3.  Obtaining and Changing Window Properties
  4775.  
  4776. Xlib provides functions with which you can obtain, rotate,
  4777. or change a window property.  In addition, Xlib provides
  4778. other utility functions for predefined property operations.
  4779. See Chapter 9 for further information about predefined pro-
  4780. perty functions.
  4781.  
  4782.  
  4783.  
  4784.  
  4785.  
  4786.                      December 18, 1987
  4787.  
  4788.  
  4789.  
  4790.  
  4791.  
  4792.                            - 68 -
  4793.  
  4794.  
  4795. Use XGetWindowProperty to obtain the atom type and property
  4796. format for a specified window. The definition for this func-
  4797. tion is:
  4798.  
  4799.  
  4800. int XGetWindowProperty(display, w, property, long_offset, long_length, delete, req_type,
  4801.                         actual_type_return, actual_format_return, nitems_return, bytes_after_return,
  4802.                         prop_return)
  4803.       Display *display;
  4804.       Window w;
  4805.       Atom property;
  4806.       long long_offset, long_length;
  4807.       Bool delete;
  4808.       Atom req_type;
  4809.       Atom *actual_type_return;
  4810.       int *actual_format_return;
  4811.       unsigned long *nitems_return;
  4812.       long *bytes_after_return;
  4813.       unsigned char **prop_return;
  4814.  
  4815.  
  4816. display   Specifies the connection to the X server.
  4817.  
  4818. w         Specifies the window ID.  This is the window whose
  4819.           atom type and property format you want to obtain.
  4820.  
  4821. property  Specifies the property atom.
  4822.  
  4823. long_offsetSpecifies the offset in the specified property
  4824.           (in 32-bit quantities) where data will be
  4825.           retrieved.
  4826.  
  4827. long_lengthSpecifies the length in 32-bit multiples of the
  4828.           data to be retrieved.
  4829.  
  4830. delete    Specifies a boolean value that determines whether
  4831.           the property is deleted from the window.  You can
  4832.           pass one of these constants:  True or False.
  4833.  
  4834. req_type  Specifies the atom identifier associated with the
  4835.           property type.  You can pass an atom identifier or
  4836.           the constant AnyPropertyType.
  4837.  
  4838. actual_type_returnReturns the atom identifier  that defines
  4839.           the actual type of the property.
  4840.  
  4841. actual_format_returnReturns the actual format of the pro-
  4842.           perty.
  4843.  
  4844. nitems_returnReturns the actual number of 8-bit, 16-bit, or
  4845.           32-bit items transferred.
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.                      December 18, 1987
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858.                            - 69 -
  4859.  
  4860.  
  4861. bytes_after_returnReturns the number of bytes remaining.
  4862.           This is the number of bytes remaining to be read
  4863.           in the property if a partial read was performed.
  4864.  
  4865. prop_returnReturns a pointer to the data, in the specified
  4866.           format.
  4867.  
  4868. The XGetWindowProperty function returns the actual type of
  4869. the property; the actual format of the property; the number
  4870. of 8-bit, 16-bit, or 32-bit items transferred; the number of
  4871. bytes remaining to be read in the property; and a pointer to
  4872. the data actually returned.  This function sets the return
  4873. arguments according to the following:
  4874.  
  4875. o    If the specified property does not exist for the speci-
  4876.      fied window, XGetWindowProperty returns the constant
  4877.      None to the actual_type_return argument and the value
  4878.      zero (0) to the actual_format_return and
  4879.      bytes_after_return arguments.  The nitems_return argu-
  4880.      ment is empty.  In this case, the delete argument is
  4881.      ignored.
  4882.  
  4883. o    If the specified property exists, but its type does not
  4884.      match the specified type, XGetWindowProperty returns
  4885.      the actual property type to the actual_type_return
  4886.      argument; the actual property format (never zero) to
  4887.      the actual_format_return argument; and the property
  4888.      length in bytes (even if the actual_format_return is 16
  4889.      or 32) to the bytes_after_return argument.  It also
  4890.      ignores the delete argument.  The nitems_return argu-
  4891.      ment is empty.
  4892.  
  4893. o    If the specified property exists, and either you assign
  4894.      the constant AnyPropertyType to the req_type argument
  4895.      or the specified type matches the actual property type,
  4896.      XGetWindowProperty returns the the actual property type
  4897.      to the actual_type_return argument and the actual pro-
  4898.      perty format (never zero) to the actual_format_return
  4899.      argument. It also returns a value to the
  4900.      bytes_after_return and nitems_return arguments, by
  4901.      defining the following values:
  4902.  
  4903.           N = actual length of the stored property in bytes
  4904.               (even if the format is 16 or 32)
  4905.           I = 4 * long_offset
  4906.           T = N - I
  4907.           L = MINIMUM(T, 4 * long_length)
  4908.           A = N - (I + L)
  4909.  
  4910.      The returned value starts at byte index I in the pro-
  4911.      perty (indexing from zero), and its length in bytes is
  4912.      L.  A BadValue error is returned if the value for
  4913.      long_offset causes L to be negative. The value of
  4914.      bytes_after_return is A, giving the number of trailing
  4915.  
  4916.  
  4917.  
  4918.                      December 18, 1987
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.                            - 70 -
  4925.  
  4926.  
  4927.      unread bytes in the stored property.
  4928.  
  4929.      If delete is True and bytes_after_return is zero (0)
  4930.      the function deletes the property from the window and
  4931.      generates a PropertyNotify event on the window.
  4932.  
  4933. XGetWindowProperty allocates one extra byte and sets it to
  4934. ASCII null, so that simple properties consisting of charac-
  4935. ters do not have to be copied into yet another string before
  4936. use.  The function returns Success if it executes success-
  4937. fully.
  4938.  
  4939. The errors that can be generated by XGetWindowProperty are
  4940. BadAtom, BadValue, and BadWindow.
  4941.  
  4942.  
  4943. Use XListProperties to obtain a property list for a speci-
  4944. fied window. The definition for this function is:
  4945.  
  4946. Atom *XListProperties(display, w, num_prop_return)
  4947.       Display *display;
  4948.       Window w;
  4949.       int *num_prop_return;
  4950.  
  4951.  
  4952. display   Specifies the connection to the X server.
  4953.  
  4954. w         Specifies the window ID.  This is the window whose
  4955.           property list you want to obtain.
  4956.  
  4957. num_prop_returnReturns the length of the properties array.
  4958.  
  4959. The XListProperties function returns a pointer to an array
  4960. of atom properties that are defined for the specified win-
  4961. dow.  Use XFree to free the memory allocated by this func-
  4962. tion.  (See Section 2.4 for further information.)
  4963.  
  4964. The error that can be generated by XListProperties is
  4965. BadWindow.
  4966.  
  4967.  
  4968. Use XChangeProperty to change the property for a specified
  4969. window. The definition for this function is:
  4970.  
  4971. XChangeProperty(display, w, property, type, format, mode, data, nelements)
  4972.       Display *display;
  4973.       Window w;
  4974.       Atom property, type;
  4975.       int format;
  4976.       int mode;
  4977.       unsigned char *data;
  4978.       int nelements;
  4979.  
  4980.  
  4981.  
  4982.  
  4983.  
  4984.                      December 18, 1987
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.                            - 71 -
  4991.  
  4992.  
  4993. display   Specifies the connection to the X server.
  4994.  
  4995. w         Specifies the window ID.  This is the window whose
  4996.           property you want to change.
  4997.  
  4998. property  Specifies the property atom.  The property remains
  4999.           defined even after the client who defined it goes
  5000.           away.  The property becomes undefined if the
  5001.           application calls XDeleteProperty, if the applica-
  5002.           tion destroys the specified window, or if the
  5003.           application closes the last connection to the X
  5004.           server.
  5005.  
  5006. type      Specifies the type of the property.  The X server
  5007.           does not interpret the type but simply passes it
  5008.           back to an application that later calls XGetPro-
  5009.           perty.
  5010.  
  5011. format    Specifies whether the data should be viewed as a
  5012.           list of 8-bit, 16-bit, or 32-bit quantities.  This
  5013.           information allows the X server to correctly per-
  5014.           form byte-swap operations as necessary.  If the
  5015.           format is 16-bit or 32-bit, you must explicitly
  5016.           cast your data pointer to a (char *) in the call
  5017.           to XChangeProperty.  Possible values are 8, 16,
  5018.           and 32.
  5019.  
  5020. mode      Specifies the mode of the operation.  You can pass
  5021.           one of these constants:  PropModeReplace, PropMo-
  5022.           dePrepend, or PropModeAppend.
  5023.  
  5024. data      Specifies the property data.
  5025.  
  5026. nelements Specifies the number of elements of the specified
  5027.           data format (8-bit, 16-bit, or 32-bit).
  5028.  
  5029. The XChangeProperty function alters the property for the
  5030. specified window and causes the X server to generate a Pro-
  5031. pertyNotify event on that window.  XChangeProperty does the
  5032. following according to the value you assign to the mode
  5033. argument:
  5034.  
  5035. o    If the mode argument is PropModeReplace, XChangePro-
  5036.      perty discards the previous property value.
  5037.  
  5038. o    If the mode argument is PropModePrepend or PropModeAp-
  5039.      pend, the type and format must match the existing pro-
  5040.      perty value. Otherwise, a BadMatch error is returned.
  5041.      If the property is undefined, it is treated as defined
  5042.      with the correct type and format with zero-length data.
  5043.  
  5044.      For PropModePrepend, the function inserts the data
  5045.      before the beginning of the existing data.  For PropMo-
  5046.      deAppend, the function appends the data onto the end of
  5047.  
  5048.  
  5049.  
  5050.                      December 18, 1987
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.                            - 72 -
  5057.  
  5058.  
  5059.      the existing data.
  5060.  
  5061. The lifetime of a property is not tied to the storing
  5062. client.  Properties remain until explicitly deleted, or the
  5063. window is destroyed, or until the server resets.  See Sec-
  5064. tion 2.5 for a discussion of what happens when the connec-
  5065. tion to the X server is closed.  The maximum size of a pro-
  5066. perty is server dependent and may vary dynamically, depend-
  5067. ing on the amount of memory the server has available.
  5068.  
  5069. The other event errors that can be generated by XChangePro-
  5070. perty are BadWindow, BadAtom, BadAlloc, and BadValue.
  5071.  
  5072.  
  5073. Use XRotateWindowProperties to rotate properties in the pro-
  5074. perties array.  The definition for this function is:
  5075.  
  5076.  
  5077. XRotateWindowProperties(display, w, properties, num_prop, npositions)
  5078.       Display *display;
  5079.       Window w;
  5080.       Atom properties[];
  5081.       int num_prop;
  5082.       int npositions;
  5083.  
  5084.  
  5085. display   Specifies the connection to the X server.
  5086.  
  5087. w         Specifies the window ID.
  5088.  
  5089. propertiesSpecifies the array of properties that are to be
  5090.           rotated.
  5091.  
  5092. num_prop  Specifies the length of the properties array.
  5093.  
  5094. npositionsSpecifies the rotation amount.
  5095.  
  5096. The XRotateWindowProperties function allows you to rotate
  5097. properties in the properties array and causes the X server
  5098. to generate a PropertyNotify event.  If the property names
  5099. in the properties array are viewed as being numbered start-
  5100. ing from zero and if there are num_prop property names in
  5101. the list, then the value associated with property name I
  5102. becomes the value associated with property name (I + nposi-
  5103. tions) mod N, for all I from zero to N - 1.  The effect is
  5104. to rotate the states by npositions places around the virtual
  5105. ring of property names (right for positive npositions, left
  5106. for negative npositions).  If npositions mod N is nonzero,
  5107. the X server generates a PropertyNotify event for each pro-
  5108. perty in the order that they are listed in the array.  If an
  5109. atom occurs more than once in the list or no property with
  5110. that name is defined for the window, a BadMatch error is
  5111. generated.  If a BadAtom or BadMatch error is generated, no
  5112. properties are changed.
  5113.  
  5114.  
  5115.  
  5116.                      December 18, 1987
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.                            - 73 -
  5123.  
  5124.  
  5125. The other error that can be generated by XRotateWindowPro-
  5126. perties is BadWindow.
  5127.  
  5128.  
  5129. Use XDeleteProperty to delete a property for the specified
  5130. window. The definition for this function is:
  5131.  
  5132. XDeleteProperty(display, w, property)
  5133.       Display *display;
  5134.       Window w;
  5135.       Atom property;
  5136.  
  5137.  
  5138. display   Specifies the connection to the X server.
  5139.  
  5140. w         Specifies the window ID.  This is the window whose
  5141.           property you want to delete.
  5142.  
  5143. property  Specifies the property atom.
  5144.  
  5145. The XDeleteProperty function deletes the specified property
  5146. only if the property was defined on the specified window.
  5147. XDeleteProperty causes the X server to generate a Proper-
  5148. tyNotify event on the window, unless the property does not
  5149. exist.
  5150.  
  5151. The errors that can be generated by XDeleteProperty are
  5152. BadWindow and BadAtom.
  5153.  
  5154. 4.4.  Manipulating Window Selection
  5155.  
  5156. A selection can be thought of as an indirect property with a
  5157. dynamic type.  That is, rather than having the property
  5158. stored in the X server, the property is maintained by some
  5159. client (the owner).  A selection is global in nature, being
  5160. thought of as belonging to the user but maintained by
  5161. clients, rather than being private to a particular window
  5162. subhierarchy or a particular set of clients.  When a client
  5163. asks for the contents of a selection, it specifies a selec-
  5164. tion target type.  This target type can be used to control
  5165. the transmitted representation of the contents.  For exam-
  5166. ple, if the selection is ``the last thing the user clicked
  5167. on,'' and that is currently an image, then the target type
  5168. might specify whether the contents of the image should be
  5169. sent in XYFormat or ZFormat.
  5170.  
  5171. The target type can also be used to control the class of
  5172. contents transmitted, for example, asking for the ``looks''
  5173. (fonts, line spacing, indentation, and so forth) of a para-
  5174. graph selection, not the text of the paragraph.  The target
  5175. type can also be used for other purposes.  The semantics are
  5176. not constrained by the protocol.
  5177.  
  5178. Xlib provides functions with which you can set, get, or
  5179.  
  5180.  
  5181.  
  5182.                      December 18, 1987
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.                            - 74 -
  5189.  
  5190.  
  5191. convert window selection.  This allows applications to
  5192. implement the notion of current selection, which requires
  5193. notification be sent to applications when they no longer own
  5194. the selection.  Applications that support selection often
  5195. highlight the current selection and need to be able to be
  5196. informed when some other application has acquired the selec-
  5197. tion in order to be able to unhighlight the selection.
  5198.  
  5199.  
  5200. Use XSetSelectionOwner to set the selection owner.  The
  5201. definition for this function is:
  5202.  
  5203. XSetSelectionOwner(display, selection, owner, time)
  5204.       Display *display;
  5205.       Atom selection;
  5206.       Window owner;
  5207.       Time time;
  5208.  
  5209.  
  5210. display   Specifies the connection to the X server.
  5211.  
  5212. selection Specifies the selection atom.
  5213.  
  5214. owner     Specifies the owner of the specified selection
  5215.           atom.  You can pass a window ID or the constant
  5216.           None.
  5217.  
  5218. time      Specifies the time.  You can pass either a times-
  5219.           tamp, expressed in milliseconds, or the constant
  5220.           CurrentTime.
  5221.  
  5222. The XSetSelectionOwner function changes the owner and last
  5223. change time for the specified selection.  The function has
  5224. no effect if the value you pass to the time argument is ear-
  5225. lier than the current last-change time of the specified
  5226. selection or is later than the current X server time.  Oth-
  5227. erwise, the last-change time is set to the specified time,
  5228. with CurrentTime replaced by the current server time.  If
  5229. the owner window is specified as None, then the owner of the
  5230. selection becomes None (that is, no owner).  Otherwise the
  5231. owner of the selection becomes the client executing the
  5232. request.
  5233.  
  5234. If the new owner (whether a client or None) is not the same
  5235. as the current owner of the selection, and the current owner
  5236. is not None, the current owner is sent a SelectionClear
  5237. event.  If the client that is the owner of a selection is
  5238. later terminated (that is, its connection is closed) or if
  5239. the owner window it has specified in the request is later
  5240. destroyed, the owner of the selection automatically reverts
  5241. to None, but the last-change time is not affected.  The
  5242. selection atom is uninterpreted by the X server.  The owner
  5243. window is returned by the XGetSelectionOwner function and is
  5244. reported in SelectionRequest and SelectionClear events.
  5245.  
  5246.  
  5247.  
  5248.                      December 18, 1987
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.                            - 75 -
  5255.  
  5256.  
  5257. Selections are global to the X server.
  5258.  
  5259. The errors that can be generated by XSetSelectionOwner are
  5260. BadWindow and BadAtom.
  5261.  
  5262.  
  5263. Use XGetSelectionOwner to return selection owner.  The
  5264. definition for this function is:
  5265.  
  5266. Window XGetSelectionOwner(display, selection)
  5267.       Display *display;
  5268.       Atom selection;
  5269.  
  5270.  
  5271. display   Specifies the connection to the X server.
  5272.  
  5273. selection Specifies the selection atom.  This is the atom
  5274.           whose owner you want returned.
  5275.  
  5276. The XGetSelectionOwner function returns the window ID asso-
  5277. ciated with the window that currently owns the specified
  5278. selection.  If no selection was specified, the function
  5279. returns the constant None.  If None is returned, there is no
  5280. owner for the selection.
  5281.  
  5282. The error that can be generated by XGetSelectionOwner is
  5283. BadAtom.
  5284.  
  5285.  
  5286. Use XConvertSelection to request a selection conversion.
  5287. The definition for this function is:
  5288.  
  5289. XConvertSelection(display, selection, target, property, requestor, time)
  5290.       Display *display;
  5291.       Atom selection, target;
  5292.       Atom property;
  5293.       Window requestor;
  5294.       Time time;
  5295.  
  5296.  
  5297. display   Specifies the connection to the X server.
  5298.  
  5299. selection Specifies the selection atom.
  5300.  
  5301. target    Specifies the target atom.
  5302.  
  5303. property  Specifies the property atom.  You also can pass
  5304.           the constant None.
  5305.  
  5306. requestor Specifies the requestor.
  5307.  
  5308. time      Specifies the time.  You can pass either a times-
  5309.           tamp, expressed in milliseconds, or the constant
  5310.           CurrentTime.
  5311.  
  5312.  
  5313.  
  5314.                      December 18, 1987
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.                            - 76 -
  5321.  
  5322.  
  5323. XConvertSelection requests that the specified selection be
  5324. converted to the specified target type:
  5325.  
  5326. o    If the specified selection has an owner, the X server
  5327.      sends a SelectionRequest event to that owner.
  5328.  
  5329. o    If no owner for the specified selection exists, the X
  5330.      server generates a SelectionNotify event to the reques-
  5331.      tor with property None.  The arguments are passed on
  5332.      unchanged in either event.
  5333.  
  5334. There are two predefined selection atoms: ``PRIMARY'' and
  5335. ``SECONDARY''.  See Chapter 8 for more information on
  5336. events, and in particular the SelectionNotify event.
  5337.  
  5338. The errors that can be generated by XConvertSelection are
  5339. BadWindow and BadAtom.
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.  
  5368.  
  5369.  
  5370.  
  5371.  
  5372.  
  5373.  
  5374.  
  5375.  
  5376.  
  5377.  
  5378.  
  5379.  
  5380.                      December 18, 1987
  5381.  
  5382.  
  5383.  
  5384.  
  5385.  
  5386.                            - 77 -
  5387.  
  5388.  
  5389.  
  5390.  
  5391.                          Chapter 5
  5392.  
  5393.                 Graphics Resource Functions
  5394.  
  5395.  
  5396.  
  5397. Chapter 5 - Graphics Resource Functions After you connect
  5398. your program to the X server by calling XOpenDisplay, you
  5399. can use the Xlib graphics resource functions to:
  5400.  
  5401. o    Manipulate the color map
  5402.  
  5403. o    Manipulate pixmaps
  5404.  
  5405. o    Manipulate graphics context/state
  5406.  
  5407. o    Use GC convenience routines
  5408.  
  5409. There are a number of resources used when performing graph-
  5410. ics operations in X.  Most information about performing
  5411. graphics (for example, foreground color, background color,
  5412. line style, and so on) are stored in resources called graph-
  5413. ics contexts.  Most graphics operations (see chapter 6) take
  5414. a graphics context or ``GC'' as an argument.  While it, in
  5415. theory, is possible to share GCs between applications, it is
  5416. expected that applications will use their own GCs when per-
  5417. forming operations, and such use is highly discouraged
  5418. because the library may cache GC state.
  5419.  
  5420. Windows in X always have an associated color map that pro-
  5421. vides a level of indirection between pixel values and color
  5422. displayed on the screen.  Many of the hardware displays
  5423. built today have a single color map, so the primitives are
  5424. written to encourage sharing of color map entries between
  5425. applications.  Because color maps are associated with win-
  5426. dows, X will support displays with multiple color maps and,
  5427. indeed, different types of color maps.  If there are not
  5428. sufficient color map resources in the display, some windows
  5429. may not be displayed in their true colors.  A window manager
  5430. can set which windows are displayed in their true colors if
  5431. more than one color map is required for the color resources
  5432. the applications are using.
  5433.  
  5434. Off screen memory or pixmaps are often used to define fre-
  5435. quently used images for later use in graphics operations.
  5436. Pixmaps are also used to define tiles or patterns for use as
  5437. window backgrounds, borders, or cursors.  A single bit plane
  5438. pixmap is sometimes referred to as a bitmap.  There may not
  5439. be an unlimited amount of off screen memory, so it should be
  5440. regarded as a precious resource.
  5441.  
  5442. Graphics operations can be performed to either windows or
  5443.  
  5444.  
  5445.  
  5446.                      December 18, 1987
  5447.  
  5448.  
  5449.  
  5450.  
  5451.  
  5452.                            - 78 -
  5453.  
  5454.  
  5455. pixmaps, also called drawables, in the discussion below and
  5456. in the next chapter.  Each drawable exists on a single
  5457. screen or root and can only be used on that root.  GCs can
  5458. also only be used with drawables of matching roots and
  5459. depths.
  5460.  
  5461. 5.1.  Manipulating the Color Map
  5462.  
  5463. Xlib provides functions with which you can manipulate a
  5464. color map.  This section discusses how to:
  5465.  
  5466. o    Create, copy, and destroy the color map
  5467.  
  5468. o    Allocate and deallocate colors
  5469.  
  5470. 5.1.1.  Creating, Copying, and Destroying Color Maps
  5471.  
  5472. Xlib provides functions with which you can create, copy,
  5473. free, or set a color map.  Color Map Manipulation
  5474.  
  5475. The following functions manipulate the representation of
  5476. color on the screen.  For each possible value a pixel may
  5477. take on a display, there is a color cell in the color map.
  5478. For example, if a display is 4 bits deep, pixel values 0
  5479. through 15 are defined. A color map is the collection of the
  5480. color cells.  A color cell consists of a triple of red,
  5481. green, and blue.  As each pixel is read out of display
  5482. memory, its value is taken and looked up in the color map.
  5483. The values of the cell determine what color is displayed on
  5484. the screen.  On a multiplane  display with a black and white
  5485. monitor (grayscale, but not color), these values may or may
  5486. not be combined to determine the brightness on the screen.
  5487.  
  5488. Screens always have a color map.  Programs will typically
  5489. allocate cells out of a common map.  It is highly
  5490. discouraged to write applications which monopolize color
  5491. resources.  On a screen that either cannot load the color
  5492. map or cannot have a fully independent color map, only cer-
  5493. tain kinds of allocations may work.  One or more (on certain
  5494. hardware) color maps may be resident at one time.  The XIn-
  5495. stallColormap function (see Chapter 7) is used to install a
  5496. color map.  The DefaultVisual macro returns the default
  5497. visual type for the specified screen.  Color maps are local
  5498. to a particular screen.  The DefaultColormap macro returns
  5499. the type of color map.  Possible types are represented by
  5500. these constants: StaticGray, GrayScale, StaticColor, Pseu-
  5501. doColor, TrueColor, or DirectColor.  These types are more
  5502. fully discussed in the section on visual types in Chapter 3.
  5503.  
  5504.                             Note
  5505.  
  5506.      The introduction of color changes the view a pro-
  5507.      grammer should take when dealing with a bitmap
  5508.      display.  For example, when printing text, you
  5509.  
  5510.  
  5511.  
  5512.                      December 18, 1987
  5513.  
  5514.  
  5515.  
  5516.  
  5517.  
  5518.                            - 79 -
  5519.  
  5520.  
  5521.      write in a color (pixel value) rather than setting
  5522.      or clearing bits.  Hardware will impose limits
  5523.      (number of significant bits, for example) on these
  5524.      values.  Typically, one allocates particular pixel
  5525.      values or sets of values.  If read only, the pixel
  5526.      values may be shared among multiple applications.
  5527.      If read/write, they are exclusively owned by the
  5528.      program, and the color cell associated with the
  5529.      pixel value may be changed at will.
  5530.  
  5531.  
  5532. The functions in this section operate on an XColor struc-
  5533. ture:
  5534.  
  5535. typedef struct {
  5536.      unsigned long pixel;/* pixel value */
  5537.      unsigned short red, green, blue;/* rgb values */
  5538.      char flags;         /* DoRed, DoGreen, DoBlue */
  5539.      char pad;
  5540. } XColor;
  5541.  
  5542.  
  5543. The red, green and blue values are scaled between 0 and
  5544. 65535. That is, on full in a color is a value of 65535
  5545. independent of the number of bit planes of the display.
  5546. Half brightness in a color would be a value of 32767 and off
  5547. would be 0.  This representation gives uniform results for
  5548. color values across displays with different number of bit
  5549. planes.
  5550.  
  5551. The flags member, which can be one or more of DoRed,
  5552. DoGreen, and DoBlue, is used in some functions to control
  5553. which members will be set.
  5554.  
  5555.  
  5556. Use XCreateColormap to create a color map for the screen on
  5557. which the window resides and to return the Colormap ID. The
  5558. definition for this function is:
  5559.  
  5560. Colormap XCreateColormap(display, w, visual, alloc)
  5561.       Display *display;
  5562.       Window w;
  5563.       Visual *visual;
  5564.       int alloc;
  5565.  
  5566.  
  5567. display   Specifies the connection to the X server.
  5568.  
  5569. w         Specifies the window ID.  This is the window on
  5570.           whose screen you want to create a color map.
  5571.  
  5572. visual    Specifies a pointer to a visual type supported on
  5573.           the screen.  If the visual type is not one sup-
  5574.           ported by the screen, the function returns a
  5575.  
  5576.  
  5577.  
  5578.                      December 18, 1987
  5579.  
  5580.  
  5581.  
  5582.  
  5583.  
  5584.                            - 80 -
  5585.  
  5586.  
  5587.           BadMatch error.
  5588.  
  5589. alloc     Specifies the color map entries to be allocated.
  5590.           You can pass one of these constants: AllocNone or
  5591.           AllocAll.
  5592.  
  5593. The XCreateColormap function creates a color map of the
  5594. specified visual type for the screen on which the window
  5595. resides and associates the Colormap ID with it.
  5596. XCreateColormap operates on a Visual structure, whose
  5597. members contain information about the color mapping that is
  5598. possible.
  5599.  
  5600. The members of this structure pertinent to the discussion of
  5601. XCreateColormap are class, red_mask, green_mask, blue_mask,
  5602. and map_entries.  The class member specifies the screen
  5603. class and can be one of these constants:  GrayScale, Pseu-
  5604. doColor, DirectColor, StaticColor, StaticGray, or TrueColor.
  5605. The red_mask, green_mask, and blue_mask members specify the
  5606. color mask values.  The map_entries member specifies the
  5607. color map entries.  The class member constant determines
  5608. whether the initial values for map_entries are defined.  If
  5609. the class member is GrayScale, PseudoColor, or DirectColor,
  5610. the initial values for map_entries are undefined.  However,
  5611. if the class member is StaticColor, StaticGray, or
  5612. TrueColor, map_entries has initial values that are defined.
  5613. These values are specific to the visual type and are not
  5614. defined by the X server.
  5615.  
  5616. The class member constant also determines the constant you
  5617. should pass to the alloc argument:
  5618.  
  5619. o    If the class member is StaticGray, StaticColor, or
  5620.      TrueColor you must pass AllocNone.  Otherwise, the
  5621.      function returns a BadMatch error.
  5622.  
  5623. o    If the class member is any other class, you can pass
  5624.      AllocNone.  In this case, the color map has no values
  5625.      defined for map_entries.  This allows your client pro-
  5626.      grams to allocate the entries in the color map.  You
  5627.      can also pass AllocAll.  In this case, XCreateColormap
  5628.      allocates the entire color map as writable.  The ini-
  5629.      tial values of all map_entries are undefined.  You can-
  5630.      not free any of these map_entries with a call to the
  5631.      function XFreeColors.
  5632.  
  5633.      For a color map class of GrayScale or PseudoColor, the
  5634.      processing simulates a call to the function XAlloc-
  5635.      Color, where XAllocColor returns all pixel values from
  5636.      zero to N - 1.  The value N represents the map_entries
  5637.      value in the specified Visual structure.  For a color
  5638.      map class of DirectColor, the processing simulates a
  5639.      call to the function XAllocColorPlanes, where XAlloc-
  5640.      ColorPlanes returns a pixel value of zero and rmask,
  5641.  
  5642.  
  5643.  
  5644.                      December 18, 1987
  5645.  
  5646.  
  5647.  
  5648.  
  5649.  
  5650.                            - 81 -
  5651.  
  5652.  
  5653.      gmask, and bmask values containing the same bits as the
  5654.      red_mask, green_mask, and blue_mask members in the
  5655.      specified Visual structure.
  5656.  
  5657. The other event errors that can be generated by
  5658. XCreateColormap are BadWindow, BadAlloc, BadMatch, and Bad-
  5659. Value.
  5660.  
  5661.  
  5662.  
  5663. Use XCopyColormapAndFree to obtain a new color map when
  5664. allocating out of a previously shared color map has failed
  5665. due to resource exhaustion. That is, too many cells or
  5666. planes were in use in the original color map.  The defini-
  5667. tion for this function is:
  5668.  
  5669. Colormap XCopyColormapAndFree(display, cmap)
  5670.       Display *display;
  5671.       Colormap cmap;
  5672.  
  5673.  
  5674. display   Specifies the connection to the X server.
  5675.  
  5676. cmap      Specifies the color map ID.
  5677.  
  5678. XCopyColormapAndFree:
  5679.  
  5680. o    Creates a colormap of the same visual type and for the
  5681.      same screen as the cmap argument and returns  the new
  5682.      colormap ID.
  5683.  
  5684. o    Moves all of the client's existing allocation from cmap
  5685.      to the new colormap with their color values intact and
  5686.      their read-only or writable characteristics intact and
  5687.      frees those entries.  Color values in other entries in
  5688.      the new colormap are undefined.
  5689.  
  5690. o    If cmap was created by the client with the alloc argu-
  5691.      ment set to AllocAll, the new colormap is also created
  5692.      with AllocAll all color values for all entries are
  5693.      copied from cmap, and then all entries in cmap are
  5694.      freed.
  5695.  
  5696. o    If cmap was not created by those clients with AllocAll,
  5697.      the allocations to be moved are all those pixels and
  5698.      planes that have been allocated by the client using
  5699.      XAllocColor, XAllocNamedColor, XAllocColorCells, or
  5700.      XAllocColorPlanes and which have not been freed since
  5701.      they were allocated.
  5702.  
  5703. The errors that can be generated by XCopyColormapAndFree are
  5704. BadAlloc and BadColor.
  5705.  
  5706.  
  5707.  
  5708.  
  5709.  
  5710.                      December 18, 1987
  5711.  
  5712.  
  5713.  
  5714.  
  5715.  
  5716.                            - 82 -
  5717.  
  5718.  
  5719. Use XFreeColormap to delete the association between the
  5720. Colormap resource ID and the color map. The definition for
  5721. this function is:
  5722.  
  5723. XFreeColormap(display, cmap)
  5724.       Display *display;
  5725.       Colormap cmap;
  5726.  
  5727.  
  5728. display   Specifies the connection to the X server.
  5729.  
  5730. cmap      Specifies the color map ID.  This is the color map
  5731.           associated with the resource ID you want to
  5732.           delete.
  5733.  
  5734. The XFreeColormap function deletes the association between
  5735. the colormap resource ID and the color map.  However, this
  5736. function has no effect on a default color map for a screen.
  5737. If cmap is an installed map for a screen it is uninstalled.
  5738. See XUninstallColormap.  If cmap is defined as the color map
  5739. for a window (by XCreateWindow or XChangeWindowAttributes)
  5740. XFreeColormap changes the color map associated with the win-
  5741. dow to None and generates a ColormapNotify event.  The
  5742. colors displayed for a window with a colormap of None are
  5743. not defined by X.
  5744.  
  5745. The error that can be generated by XFreeColormap is Bad-
  5746. Color.
  5747.  
  5748.  
  5749. Use XSetWindowColormap to set the color map for a specified
  5750. window. The definition for this function is:
  5751.  
  5752. XSetWindowColormap(display, w, cmap)
  5753.       Display *display;
  5754.       Window w;
  5755.       Colormap cmap;
  5756.  
  5757.  
  5758. display   Specifies the connection to the X server.
  5759.  
  5760. w         Specifies the window ID.  This is the window to
  5761.           which you want to set the color map.
  5762.  
  5763. cmap      Specifies the color map ID.
  5764.  
  5765. The XSetWindowColormap function sets the specified color map
  5766. of the specified window.
  5767.  
  5768. The errors that can be generated by XSetWindowColormap are
  5769. BadWindow, BadColor, and BadMatch.
  5770.  
  5771.  
  5772.  
  5773.  
  5774.  
  5775.  
  5776.                      December 18, 1987
  5777.  
  5778.  
  5779.  
  5780.  
  5781.  
  5782.                            - 83 -
  5783.  
  5784.  
  5785. 5.1.2.  Allocating and Freeing Colors
  5786.  
  5787. Xlib provides functions with which you can allocate or deal-
  5788. locate colors.  There are two ways of allocating color
  5789. cells: explicitly as read only entries by pixel value or
  5790. read/write, where you can allocate N colors and planes
  5791. simultaneously.  The read/write cells you allocate do not
  5792. have defined colors until set with XStoreColors.
  5793.  
  5794. To determine the color names, the X server uses a color data
  5795. base.  On a UNIX-based system, this data base is
  5796. /usr/lib/rgb, and a printable copy of it is stored in
  5797. /usr/lib/rgb.txt.  The name and contents of this file are
  5798. operating system specific.
  5799.  
  5800.  
  5801. Use XAllocColor to obtain the closest color provided by the
  5802. hardware. The definition for this function is:
  5803.  
  5804. Status XAllocColor(display, cmap, screen_def_return)
  5805.       Display *display;
  5806.       Colormap cmap;
  5807.       XColor *screen_def_return;
  5808.  
  5809.  
  5810. display   Specifies the connection to the X server.
  5811.  
  5812. cmap      Specifies the color map ID.
  5813.  
  5814. screen_def_returnReturns the values actually used in the
  5815.           color map.
  5816.  
  5817. The XAllocColor function returns the pixel value indicating
  5818. the closest color supported by the hardware.  It also
  5819. returns the red, green, and blue values actually used.  XAl-
  5820. locColor allocates a read-only color map entry corresponding
  5821. to the closest red, green, and blue values supported by the
  5822. hardware.  The corresponding color map cell is read-only.
  5823. In addition, XAllocColor returns zero (0) if there were some
  5824. problem (typically lack of resources) or nonzero if it suc-
  5825. ceeded.  Read-only color map cells are shared among clients.
  5826. When the last client deallocates a shared cell, it is deal-
  5827. located.
  5828.  
  5829. The errors that can be generated by XAllocColor are BadAlloc
  5830. and BadColor.
  5831.  
  5832.  
  5833. Use XAllocNamedColor to obtain the color definition struc-
  5834. ture for a specified color and the closest color supported
  5835. by the hardware.  The definition for this function is:
  5836.  
  5837.  
  5838.  
  5839.  
  5840.  
  5841.  
  5842.                      December 18, 1987
  5843.  
  5844.  
  5845.  
  5846.  
  5847.  
  5848.                            - 84 -
  5849.  
  5850.  
  5851. Status XAllocNamedColor(display, cmap, colorname, screen_def_return, exact_def_return)
  5852.       Display *display;
  5853.       Colormap cmap;
  5854.       char *colorname;
  5855.       XColor *screen_def_return, *exact_def_return;
  5856.  
  5857.  
  5858. display   Specifies the connection to the X server.
  5859.  
  5860. cmap      Specifies the color map ID.
  5861.  
  5862. colorname Specifies the color name string (for example,
  5863.           "red") whose color definition structure you want
  5864.           returned.  You should use the ISO Latin-1 encod-
  5865.           ing, and upper/lower case does not matter.
  5866.  
  5867. screen_def_returnReturns the values actually used in the
  5868.           color map.
  5869.  
  5870. exact_def_returnReturns the true pixel values that indicate
  5871.           the closest color provided by the hardware for the
  5872.           specified color name.
  5873.  
  5874. The XAllocNamedColor function determines the correct color
  5875. (shade) for the given screen.  XAllocNamedColor returns zero
  5876. (0) when it encounters an error or a nonzero when it
  5877. succeeds.  Both the exact data base definition and the
  5878. closest color supported by the hardware are returned.
  5879.  
  5880. The errors that can be generated by XAllocNamedColor are
  5881. BadColor, BadAlloc, and BadName.
  5882.  
  5883.  
  5884. Use XLookupColor to look up the name of a color.  The defin-
  5885. ition for this function is:
  5886.  
  5887. Status XLookupColor(display, cmap, colorname, screen_def_return, exact_def_return)
  5888.       Display *display;
  5889.       Colormap cmap;
  5890.       char *colorname;
  5891.       XColor *screen_def_return, *exact_def_return;
  5892.  
  5893.  
  5894. display   Specifies the connection to the X server.
  5895.  
  5896. cmap      Specifies the color map ID.
  5897.  
  5898. colorname Specifies the color name string (for example,
  5899.           "red") whose color definition structure you want
  5900.           returned.  You should use the ISO Latin-1 encod-
  5901.           ing, and upper/lower case does not matter.
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.                      December 18, 1987
  5909.  
  5910.  
  5911.  
  5912.  
  5913.  
  5914.                            - 85 -
  5915.  
  5916.  
  5917. screen_def_returnReturns the values actually used in the
  5918.           color map.
  5919.  
  5920. exact_def_returnReturns the true pixel values that indicate
  5921.           the closest color provided by the hardware for the
  5922.           specified color name.
  5923.  
  5924. The XLookupColor function looks up the string name of a
  5925. color with respect to the screen associated with the speci-
  5926. fied cmap and returns both the exact color values and the
  5927. closest values provided by the hardware with respect to the
  5928. visual type of cmap.  You should use the ISO Latin-1 encod-
  5929. ing for the name, and upper/lower case does not matter.  In
  5930. addition, XLookupColor returns nonzero if the spec existed
  5931. in the RGB data base or zero (0) if it did not exist.
  5932.  
  5933. The errors that can be generated by XLookupColor are Bad-
  5934. Color and BadName.
  5935.  
  5936.  
  5937. Use XStoreColors to set the colors of the specified pixel
  5938. values to the closest available hardware colors.  The defin-
  5939. ition for this function is:
  5940.  
  5941. XStoreColors(display, cmap, defs, ncolors)
  5942.       Display *display;
  5943.       Colormap cmap;
  5944.       XColor defs[];
  5945.       int ncolors;
  5946.  
  5947.  
  5948. display   Specifies the connection to the X server.
  5949.  
  5950. cmap      Specifies the color map ID.
  5951.  
  5952. defs      Specifies an array of color definition structures.
  5953.  
  5954. ncolors   Specifies the number of XColor structures in the
  5955.           color definition array.
  5956.  
  5957. The XStoreColors function changes the color map entries of
  5958. the pixel values specified in the pixel members of the
  5959. XColor structures.  You specify which color components to be
  5960. changed by passing the constants DoRed, DoGreen, and/or DoB-
  5961. lue to the flags members of the XColor structures.  If the
  5962. colormap is an installed map for its screen, the changes are
  5963. visible immediately.  XStoreColors changes the specified
  5964. pixels if they are allocated writable in cmap by any client,
  5965. even if one or more pixels generates an error.  A BadValue
  5966. error is generated if a specified pixel is not a valid index
  5967. into cmap and a BadAccess error is generated if a specified
  5968. pixel either is unallocated or is allocated read-only.  If
  5969. more than one pixel is in error, which one is reported is
  5970. arbitrary.
  5971.  
  5972.  
  5973.  
  5974.                      December 18, 1987
  5975.  
  5976.  
  5977.  
  5978.  
  5979.  
  5980.                            - 86 -
  5981.  
  5982.  
  5983. The other event errors that can be generated by XStoreColors
  5984. are BadAccess and BadColor.
  5985.  
  5986.  
  5987. Use XStoreColor to set the color of the specified pixel
  5988. value to the closest available hardware color. The defini-
  5989. tion for this function is:
  5990.  
  5991. XStoreColor(display, cmap, screen_def_return)
  5992.       Display *display;
  5993.       Colormap cmap;
  5994.       XColor *screen_def_return;
  5995.  
  5996.  
  5997. display   Specifies the connection to the X server.
  5998.  
  5999. cmap      Specifies the color map ID.
  6000.  
  6001. screen_def_returnReturns the values actually used in the
  6002.           color map.
  6003.  
  6004. The XStoreColor function changes the color map entry of the
  6005. pixel value specified in the pixel member of the XColor
  6006. structure.  XStoreColor changes the:
  6007.  
  6008. o    Color map entry of the pixel value. You specified this
  6009.      value in the pixel member of the XColor structure.
  6010.      This pixel value must be a read/write cell and a valid
  6011.      index into cmap.  A BadValue error is generated if a
  6012.      specified pixel is not a valid index into cmap.
  6013.  
  6014. o    Red, green, and/or blue color components.  You specify
  6015.      which color components to be changed by passing the
  6016.      constants DoRed, DoGreen, and/or DoBlue to the flags
  6017.      member of the XColor structure.  If the color map is an
  6018.      installed map for its screen, the changes are visible
  6019.      immediately.
  6020.  
  6021. o    Specified pixel if it is allocated writable in cmap by
  6022.      any client, even if the pixel generates an error.
  6023.  
  6024. The other error that can be generated by XStoreColor is Bad-
  6025. Color.
  6026.  
  6027.  
  6028. Use XAllocColorCells to allocate color cells. The definition
  6029. for this function is:
  6030.  
  6031.  
  6032.  
  6033.  
  6034.  
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040.                      December 18, 1987
  6041.  
  6042.  
  6043.  
  6044.  
  6045.  
  6046.                            - 87 -
  6047.  
  6048.  
  6049. Status XAllocColorCells(display, cmap, contig, plane_masks_return, nplanes,
  6050.                           pixels_return, ncolors)
  6051.       Display *display;
  6052.       Colormap cmap;
  6053.       Bool contig;
  6054.       unsigned long plane_masks_return[];
  6055.       unsigned int nplanes;
  6056.       unsigned long pixels_return[];
  6057.       unsigned int ncolors;
  6058.  
  6059.  
  6060. display   Specifies the connection to the X server.
  6061.  
  6062. cmap      Specifies the color map ID.
  6063.  
  6064. contig    Specifies a boolean value.  You pass the value 1
  6065.           if the planes must be contiguous or the value 0 if
  6066.           the planes do not need to be contiguous.
  6067.  
  6068. plane_mask_returnReturns an array of plane masks.
  6069.  
  6070. nplanes   Specifies the number of plane masks that are to be
  6071.           returned in the plane masks array.
  6072.  
  6073. pixels_returnReturns an array of pixel values.
  6074.  
  6075. ncolors   Specifies the number of pixel values that are to
  6076.           be returned in the pixels_return array.
  6077.  
  6078. The XAllocColorCells function allocates color cells.  The
  6079. number of colors must be positive and the number of planes
  6080. nonnegative.  Otherwise, a BadValue error is generated.  If
  6081. ncolors and nplanes are requested, then ncolors pixels and
  6082. nplane plane masks are returned.  No mask will have any bits
  6083. in common with any other mask or with any of the pixels.  By
  6084. ORing together masks and pixels, ncolors* 2nplanes distinct
  6085. pixels can be produced.  All of these are allocated writable
  6086. by the request.  For GrayScale or PseudoColor, each mask
  6087. will have exactly one bit, and, for DirectColor, each will
  6088. have exactly three bits.  If contigs is True, and if all
  6089. masks are ORed together, a single contiguous set of bits
  6090. will be formed for GrayScale or PseudoColor and three con-
  6091. tiguous sets of bits (one within each pixel subfield) for
  6092. DirectColor.  The RGB values of the allocated entries are
  6093. undefined.
  6094.  
  6095. The other event errors that can be generated by XAllocColor-
  6096. Cells are BadColor, BadValue, and BadAlloc.
  6097.  
  6098.  
  6099. Use XAllocColorPlanes to allocate color planes.  The defini-
  6100. tion for this function is:
  6101.  
  6102.  
  6103.  
  6104.  
  6105.  
  6106.                      December 18, 1987
  6107.  
  6108.  
  6109.  
  6110.  
  6111.  
  6112.                            - 88 -
  6113.  
  6114.  
  6115. Status XAllocColorPlanes(display, cmap, contig, pixels_return, ncolors, nreds, ngreens,
  6116.                            nblues, rmask_return, gmask_return, bmask_return)
  6117.       Display *display;
  6118.       Colormap cmap;
  6119.       Bool contig;
  6120.       unsigned long pixels_return[];
  6121.       int ncolors;
  6122.       int nreds, ngreens, nblues;
  6123.       unsigned long *rmask_return, *gmask_return, *bmask_return;
  6124.  
  6125.  
  6126. display   Specifies the connection to the X server.
  6127.  
  6128. cmap      Specifies the color map ID.
  6129.  
  6130. contig    Specifies a boolean value.  You pass the value 1
  6131.           if the planes must be contiguous or the value 0 if
  6132.           the planes do not need to be contiguous.
  6133.  
  6134. pixels_returnReturns an array of pixel values. XAllocColor-
  6135.           Planes returns the pixel values in this array.
  6136.  
  6137. ncolors   Specifies the number of pixel values that are to
  6138.           be returned in the pixels_return array.
  6139.  
  6140. nreds
  6141. ngreens
  6142. nblues
  6143.           Specify the number of red, green, and blue colors
  6144.           (shades).  The value you pass must be non-
  6145.           negative.
  6146.  
  6147. rmask_return
  6148. gmask_return
  6149. bmask_returnReturn bit masks for the red, green, and blue
  6150.           planes.
  6151.  
  6152. The XAllocColorPlanes function allocates color planes.  The
  6153. specified ncolors must be positive, and nreds, ngreens, and
  6154. nblues must be nonnegative.  Otherwise, a BadValue error is
  6155. generated.  If ncolors colors, nreds reds, ngreens greens,
  6156. and nblues blues are requested, ncolors pixels are returned,
  6157. and the masks have nreds, ngreens, and nblues bits set
  6158. respectively.  If contiguous is True, each mask will have a
  6159. contiguous set of bits.  No mask will have any bits in com-
  6160. mon with any other mask or with any of the pixels.  For
  6161. DirectColor, each mask will lie within the corresponding
  6162. pixel subfield.  By ORing together subsets of masks with
  6163. pixels, ncolors*2(nreds+ngreens+nblues) distinct pixels can
  6164. be produced. All of these are allocated by the request.
  6165. However, in the colormap, there are only ncolors*2nreds
  6166. independent red entries, ncolors*2ngreens independent green
  6167. entries, and ncolors*2nblues independent blue entries. This
  6168. is true even for PseudoColor.  When the colormap entry for a
  6169.  
  6170.  
  6171.  
  6172.                      December 18, 1987
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.                            - 89 -
  6179.  
  6180.  
  6181. pixel value is changed (using XStoreColors or
  6182. XStoreNamedColor), the pixel is decomposed according to the
  6183. masks, and the corresponding independent entries are
  6184. updated.
  6185.  
  6186. The other event errors that can be generated by XAllocColor-
  6187. Planes are BadAlloc, BadValue, and BadColor.
  6188.  
  6189.  
  6190. Use XStoreNamedColor to allocate a color cell by name. The
  6191. definition for this function is:
  6192.  
  6193. XStoreNamedColor(display, cmap, color, pixel, flags)
  6194.       Display *display;
  6195.       Colormap cmap;
  6196.       char *color;
  6197.       unsigned long pixel;
  6198.       int flags;
  6199.  
  6200.  
  6201. display   Specifies the connection to the X server.
  6202.  
  6203. cmap      Specifies the color map ID.
  6204.  
  6205. color     Specifies the color name string (for example,
  6206.           ``red''). The function then allocates this color
  6207.           cell.  You should use the ISO Latin-1 encoding,
  6208.           and upper/lower case does not matter.
  6209.  
  6210. pixel     Specifies the entry in the color map.
  6211.  
  6212. flags     Specifies which red, green, and blue indexes are
  6213.           set.
  6214.  
  6215. The XStoreNamedColor function looks up the named color with
  6216. respect to the screen associated with cmap and stores the
  6217. result in cmap.  The pixel argument determines the entry in
  6218. the color map.  The flags argument determines which of the
  6219. red, green, and blue indexes are set. You can set this
  6220. member to the bitwise inclusive OR of the bits from the con-
  6221. stant set DoRed, DoGreen, and DoBlue.  A BadValue error is
  6222. generated if a specified pixel is not a valid index into
  6223. cmap and a BadAccess error is generated if a specified pixel
  6224. either is unallocated or is allocated read-only.  If more
  6225. than one pixel is in error, which one is reported is arbi-
  6226. trary.
  6227.  
  6228. The errors that can be generated by XStoreNamedColor are
  6229. BadColor, BadAccess, BadName, and BadValue.
  6230.  
  6231.  
  6232. Use XFreeColors to free color map cells. The definition for
  6233. this function is:
  6234.  
  6235.  
  6236.  
  6237.  
  6238.                      December 18, 1987
  6239.  
  6240.  
  6241.  
  6242.  
  6243.  
  6244.                            - 90 -
  6245.  
  6246.  
  6247. XFreeColors(display, cmap, pixels, npixels, planes)
  6248.       Display *display;
  6249.       Colormap cmap;
  6250.       unsigned long pixels[];
  6251.       int npixels;
  6252.       unsigned long planes;
  6253.  
  6254.  
  6255. display   Specifies the connection to the X server.
  6256.  
  6257. cmap      Specifies the color map ID.
  6258.  
  6259. pixels    Specifies an array of pixel values. These pixel
  6260.           values map to the cells in the specified color
  6261.           map.
  6262.  
  6263. npixels   Specifies the number of pixels.
  6264.  
  6265. planes    Specifies the planes you want to free.
  6266.  
  6267. The XFreeColors function frees the cells represented by pix-
  6268. els whose values are in the pixels array.  The planes argu-
  6269. ment should not have any bits in common with any of the pix-
  6270. els. The set of all pixels is produced by ORing together
  6271. subsets of the planes argument with the pixels.  The request
  6272. frees all of these pixels that were allocated by the client
  6273. (using XAllocColor, XAllocNamedColor, XAllocColorCells, and
  6274. XAllocColorPlanes).  Note that freeing an individual pixel
  6275. obtained from XAllocColorPlanes may not actually allow it to
  6276. be reused until all of its related pixels are also freed.
  6277.  
  6278. All specified pixels that are allocated by the client in
  6279. cmap are freed, even if one or more pixels produce an error.
  6280. A BadValue error is generated if a specified pixel is not a
  6281. valid index into cmap.  A BadAccess error is generated if a
  6282. specified pixel is not allocated by the client (that is, is
  6283. unallocated or is only allocated by another client).  If
  6284. more than one pixel is in error, the one reported is arbi-
  6285. trary.
  6286.  
  6287. The errors that can be generated by XFreeColors are Bad-
  6288. Color, BadAccess, and BadValue.
  6289.  
  6290. 5.1.3.  Reading Entries in a Colormap
  6291.  
  6292. The XQueryColor function returns the red, green, and blue
  6293. color values stored in cmap for the pixel value you passed
  6294. to the pixel member of the XColor structure.  The values
  6295. returned for an unallocated entry are undefined.  The
  6296. XQueryColors function does the same thing, except that it
  6297. operates on an array of XColor structures.  They also set
  6298. the flags member in the XColor structure to all three
  6299. colors.  A BadValue error is generated if a pixel is not a
  6300. valid index into cmap.  If more than one pixel is in error,
  6301.  
  6302.  
  6303.  
  6304.                      December 18, 1987
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.                            - 91 -
  6311.  
  6312.  
  6313. which one is reported is arbitrary.
  6314.  
  6315.  
  6316. Use XQueryColor to obtain the color values for a single
  6317. specified pixel value. The definition for this function is:
  6318.  
  6319. XQueryColor(display, cmap, def_return)
  6320.       Display *display;
  6321.       Colormap cmap;
  6322.       XColor *def_return;
  6323.  
  6324.  
  6325. display   Specifies the connection to the X server.
  6326.  
  6327. cmap      Specifies the color map ID.
  6328.  
  6329. def_returnReturns the RGB values for the pixel specified in
  6330.           the structure.
  6331.  
  6332. The other event errors that can be generated by XQueryColor
  6333. are BadValue and BadColor.
  6334.  
  6335.  
  6336. Use XQueryColors to obtain color values for an array of pix-
  6337. els stored in color structures.  The definition for this
  6338. function is:
  6339.  
  6340. XQueryColors(display, cmap, defs_return, ncolors)
  6341.       Display *display;
  6342.       Colormap cmap;
  6343.       XColor defs_return[];
  6344.       int ncolors;
  6345.  
  6346.  
  6347. display   Specifies the connection to the X server.
  6348.  
  6349. cmap      Specifies the color map ID.
  6350.  
  6351. defs_returnReturns an array of color definition structures.
  6352.  
  6353. ncolors   Specifies the number of XColor structures in the
  6354.           color definition array.
  6355.  
  6356. The other event errors that can be generated by XQueryColors
  6357. are BadValue and BadColor.
  6358.  
  6359. 5.2.  Manipulating Pixmaps
  6360.  
  6361. Xlib provides functions with which you can create or free a
  6362. pixmap.  A few  programs may want to manipulate pixels that
  6363. they later display on the screen.  This section describes
  6364. functions that will move pixels from the program to the win-
  6365. dow system, or from the window system to the program.  You
  6366. must be careful to adhere to the data representation
  6367.  
  6368.  
  6369.  
  6370.                      December 18, 1987
  6371.  
  6372.  
  6373.  
  6374.  
  6375.  
  6376.                            - 92 -
  6377.  
  6378.  
  6379. described at the beginning of this document to keep programs
  6380. portable between machine architectures.  Pixmaps can only be
  6381. used on the screen on which they were created.
  6382.  
  6383. Pixmaps are off-screen resources that are used for a number
  6384. of operations.  A bitmap is a single bit pixmap.  These
  6385. include defining cursors or temporarily saving some part of
  6386. the screen for later, either as tiling patterns or as the
  6387. source for certain raster operations.
  6388.  
  6389.  
  6390. Use XCreatePixmap to create a pixmap of a specified size.
  6391. The definition for this function is:
  6392.  
  6393. Pixmap XCreatePixmap(display, d, width, height, depth)
  6394.       Display *display;
  6395.       Drawable d;
  6396.       unsigned int width, height;
  6397.       unsigned int depth;
  6398.  
  6399.  
  6400. display   Specifies the connection to the X server.
  6401.  
  6402. d         Specifies which screen the pixmap is created on.
  6403.  
  6404. width
  6405. height    Specify the width and height.  These dimensions
  6406.           define the width and height of the pixmap.  The
  6407.           values you pass must be nonzero.
  6408.  
  6409. depth     Specifies the depth of the pixmap.  The depth must
  6410.           be supported by the root of the specified draw-
  6411.           able.
  6412.  
  6413. The XCreatePixmap function creates a pixmap of the width,
  6414. height, and depth you specified.  It also assigns the pixmap
  6415. ID to it.  It is valid to pass a window whose class is Inpu-
  6416. tOnly to the drawable argument.  The width and height argu-
  6417. ments must be nonzero.  Otherwise, a BadValue error is gen-
  6418. erated.  The depth argument must be one of the depths sup-
  6419. ported by the root of the specified drawable.  Otherwise, a
  6420. BadValue error is generated.
  6421.  
  6422. The server uses the drawable argument to determine which
  6423. screen the pixmap is stored on.  The pixmap can only be used
  6424. on this screen and only with other drawables windows of the
  6425. same depth.  (See XCopyPlane for an exception to this rule).
  6426. The initial contents of the pixmap are undefined.  If this
  6427. routine returns zero (0), there was insufficient space for
  6428. the pixmap.
  6429.  
  6430. The errors that can be generated by XCreatePixmap are BadAl-
  6431. loc, BadDrawable, and BadValue.
  6432.  
  6433.  
  6434.  
  6435.  
  6436.                      December 18, 1987
  6437.  
  6438.  
  6439.  
  6440.  
  6441.  
  6442.                            - 93 -
  6443.  
  6444.  
  6445. Use XFreePixmap to free all storage associated with a speci-
  6446. fied pixmap. The definition for this function is:
  6447.  
  6448. XFreePixmap(display, pixmap)
  6449.       Display *display;
  6450.       Pixmap pixmap;
  6451.  
  6452.  
  6453. display   Specifies the connection to the X server.
  6454.  
  6455. pixmap    Specifies the pixmap.
  6456.  
  6457. The XFreePixmap function first deletes the association
  6458. between the pixmap ID and the pixmap.  Then, the X server
  6459. frees the pixmap storage when no other resources reference
  6460. it.  The pixmap should never be referenced again.
  6461.  
  6462. The error that can be generated by XFreePixmap is BadPixmap.
  6463.  
  6464. 5.3.  Manipulating Graphics Context/State
  6465.  
  6466. Most attributes of graphics operations are stored in Graphic
  6467. Contexts or GCs.  These include line width, line style,
  6468. plane mask, foreground, background, tile, stipple, clipping
  6469. region, end style, join style, and so on.  Graphics opera-
  6470. tions (for example, drawing lines) use these values to
  6471. determine the actual drawing operation.  Extensions to X may
  6472. add additional components to GCs.  Xlib provides calls for
  6473. changing the state of GCs.
  6474.  
  6475. Xlib implements a write-back cache for all elements of a GC
  6476. that are not resource IDs to allow it to implement the tran-
  6477. sparent coalescing changes to GCs.  GCs are neither expected
  6478. nor encouraged to be shared between client applications, so
  6479. this write-back caching should present no problems.  Appli-
  6480. cations cannot share GCs without external synchronization.
  6481. Therefore, sharing GCs between applications is highly
  6482. discouraged. Graphic Operations
  6483.  
  6484. You use display functions when you update  a section of the
  6485. screen (destination) with bits from somewhere else (source).
  6486. Many GC functions take one of these display functions as an
  6487. argument.  The function defines how the new destination bits
  6488. are to be computed from the source bits and the old destina-
  6489. tion bits.  GXcopy is typically the most useful because it
  6490. will work on a color display, but special applications may
  6491. use other functions, particularly in concert with particular
  6492. planes of a color display.  The 16 such functions, defined
  6493. in <X11/X.h>, are:
  6494.  
  6495. ___________________________________________________
  6496. Function Name    Hex Code          Operation
  6497. ___________________________________________________
  6498. GXclear            0x0      0
  6499.  
  6500.  
  6501.                      December 18, 1987
  6502.  
  6503.  
  6504.  
  6505.  
  6506.  
  6507.                            - 94 -
  6508.  
  6509.  
  6510. ___________________________________________________
  6511. Function Name    Hex Code          Operation
  6512. ___________________________________________________
  6513. GXand              0x1      src AND dst
  6514. GXandReverse       0x2      src AND NOT dst
  6515. GXcopy             0x3      src
  6516. GXandInverted      0x4      (NOT src) AND dst
  6517. GXnoop             0x5      dst
  6518. GXxor              0x6      src XOR dst
  6519. GXor               0x7      src OR dst
  6520. GXnor              0x8      (NOT src) AND (NOT dst)
  6521. GXequiv            0x9      (NOT src) XOR dst
  6522. GXinvert           0xa      NOT dst
  6523. GXorReverse        0xb      src OR (NOT dst)
  6524. GXcopyInverted     0xc      NOT src
  6525. GXorInverted       0xd      (NOT src) OR dst
  6526. GXnand             0xe      (NOT src) OR (NOT dst)
  6527. GXset              0xf      1
  6528. ___________________________________________________
  6529.  
  6530.  
  6531. Many of the color functions below take either pixel values
  6532. or planes as an argument.  The planes argument is of type
  6533. long and it specifies which planes of the display are to be
  6534. modified, one bit per plane.  A monochrome display has only
  6535. one plane and will be the least significant bit of the word.
  6536. As planes are added to the display hardware, they will
  6537. occupy more significant bits in the plane mask.
  6538.  
  6539. A macro constant AllPlanes can be used to refer to all
  6540. planes of a display simultaneously (~0).  Most operations
  6541. use an object called a GC, which is short for Graphics Con-
  6542. text. The contents of the GC object are private to the
  6543. library.  Several procedures take structures of type
  6544. GCValues. The following lists each entry by its defined
  6545. value, not by its position in the XGCValues structure:
  6546.  
  6547.  
  6548.  
  6549.  
  6550.  
  6551.  
  6552.  
  6553.  
  6554.  
  6555.  
  6556.  
  6557.  
  6558.  
  6559.  
  6560.  
  6561.  
  6562.  
  6563.  
  6564.  
  6565.  
  6566.                      December 18, 1987
  6567.  
  6568.  
  6569.  
  6570.  
  6571.  
  6572.                            - 95 -
  6573.  
  6574.  
  6575. #define GCFunction            (1L<<0)
  6576. #define GCPlaneMask           (1L<<1)
  6577. #define GCForeground          (1L<<2)
  6578. #define GCBackground          (1L<<3)
  6579. #define GCLineWidth           (1L<<4)
  6580. #define GCLineStyle           (1L<<5)
  6581. #define GCCapStyle            (1L<<6)
  6582. #define GCJoinStyle           (1L<<7)
  6583. #define GCFillStyle           (1L<<8)
  6584. #define GCFillRule            (1L<<9)
  6585. #define GCTile                (1L<<10)
  6586. #define GCStipple             (1L<<11)
  6587. #define GCTileStipXOrigin     (1L<<12)
  6588. #define GCTileStipYOrigin     (1L<<13)
  6589. #define GCFont                (1L<<14)
  6590. #define GCSubwindowMode       (1L<<15)
  6591. #define GCGraphicsExposures   (1L<<16)
  6592. #define GCClipXOrigin         (1L<<17)
  6593. #define GCClipYOrigin         (1L<<18)
  6594. #define GCClipMask            (1L<<19)
  6595. #define GCDashOffset          (1L<<20)
  6596. #define GCDashList            (1L<<21)
  6597. #define GCArcMode             (1L<<22)
  6598.  
  6599. typedef struct {
  6600.      int function;            /* logical operation */
  6601.      unsigned long plane_mask;/* plane mask */
  6602.      unsigned long foreground;/* foreground pixel */
  6603.      unsigned long background;/* background pixel */
  6604.      int line_width;          /* line width (in pixels) */
  6605.      int line_style;          /* LineSolid, LineOnOffDash, LineDoubleDash */
  6606.      int cap_style;           /* CapNotLast, CapButt, CapRound, CapProjecting */
  6607.      int join_style;          /* JoinMiter, JoinRound, JoinBevel */
  6608.      int fill_style;          /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/
  6609.      int fill_rule;           /* EvenOddRule, WindingRule */
  6610.      int arc_mode;            /* ArcChord, ArcPieSlice */
  6611.      Pixmap tile;             /* tile pixmap for tiling operations */
  6612.      Pixmap stipple;          /* stipple 1 plane pixmap for stippling */
  6613.      int ts_x_origin;         /* offset for tile or stipple operations */
  6614.      int ts_y_origin;
  6615.      Font font;               /* default text font for text operations */
  6616.      int subwindow_mode;      /* ClipByChildren, IncludeInferiors */
  6617.      Bool graphics_exposures; /* boolean, should exposures be generated */
  6618.      int clip_x_origin;       /* origin for clipping */
  6619.      int clip_y_origin;
  6620.      Pixmap clip_mask;        /* bitmap clipping; other calls for rects */
  6621.      int dash_offset;         /* patterned/dashed line information */
  6622.      char dashes;
  6623. } XGCValues;
  6624.  
  6625.  
  6626.  
  6627. Use XCreateGC to create a new graphics context for the
  6628. specified drawable. The definition for this function is:
  6629.  
  6630.  
  6631.  
  6632.                      December 18, 1987
  6633.  
  6634.  
  6635.  
  6636.  
  6637.  
  6638.                            - 96 -
  6639.  
  6640.  
  6641. GC XCreateGC(display, d, valuemask_create, values)
  6642.       Display *display;
  6643.       Drawable d;
  6644.       unsigned long valuemask_create;
  6645.       XGCValues *values;
  6646.  
  6647.  
  6648. display   Specifies the connection to the X server.
  6649.  
  6650. d         Specifies the drawable.
  6651.  
  6652. valuemask_createSpecifies which components in the graphics
  6653.           context are to be set using information in the
  6654.           XGCValues structure.  This argument is the bitwise
  6655.           inclusive OR of one or more of the valid GC com-
  6656.           ponent masks.
  6657.  
  6658. values    Specifies a pointer to the XGCValues structure.
  6659.  
  6660. The XCreateGC function creates a graphics context and
  6661. returns a GC.  The graphics context can be used with any
  6662. destination drawable having the same root and depth as the
  6663. specified drawable.  Use with other drawables results in a
  6664. BadMatch error.
  6665.  
  6666. The specified components of the new graphics context in
  6667. valuemask_create are set to the values passed in the values
  6668. argument.  The other values default to the following values:
  6669.  
  6670. __________________________________________________________________________________
  6671.      Component        Value
  6672. __________________________________________________________________________________
  6673. function:             GXcopy
  6674. plane_mask:           All ones
  6675. foreground:           0
  6676. background:           1
  6677. line_width:           0
  6678. line_style:           LineSolid
  6679. cap_style:            CapButt
  6680. join_style:           JoinMiter
  6681. fill_style:           FillSolid
  6682. fill_rule:            EvenOddRule
  6683. arc_mode:             ArcPieSlice
  6684. tile:                 Pixmap of unspecified size filled with foreground pixel
  6685.                       (that is, client specified pixel if any, else 0)
  6686.                       (subsequent changes to foreground do not affect this pixmap)
  6687. stipple:              Pixmap of unspecified size filled with ones
  6688. ts_x_origin:          0
  6689. ts_y_origin:          0
  6690. font:                 <implementation dependent>
  6691. subwindow_mode:       ClipByChildren
  6692. graphics_exposures:   True
  6693. clip_x_origin:        0
  6694. clip_y_origin:        0
  6695.  
  6696.  
  6697.                      December 18, 1987
  6698.  
  6699.  
  6700.  
  6701.  
  6702.  
  6703.                            - 97 -
  6704.  
  6705.  
  6706. __________________________________________________________________________________
  6707.      Component        Value
  6708. __________________________________________________________________________________
  6709. clip_mask:            None
  6710. dash_offset:          0
  6711. dashes:               4 (that is, the list [4, 4])
  6712. __________________________________________________________________________________
  6713.  
  6714.  
  6715. Note that foreground and background are not set to any
  6716. values likely to be useful on a color display.
  6717.  
  6718. In graphics operations, given a source and destination
  6719. pixel, the result is computed bitwise on corresponding bits
  6720. of the pixels.  That is, a boolean operation is performed in
  6721. each bit plane. The plane_mask restricts the operation to a
  6722. subset of planes.  That is, the result is computed by the
  6723. following:
  6724.  
  6725.  
  6726.         ((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask))
  6727.  
  6728. Range checking is not performed on the values for fore-
  6729. ground, background, or plane_mask.  They are simply trun-
  6730. cated to the appropriate number of bits.  The line_width is
  6731. measured in pixels and either can be greater than or equal
  6732. to one (wide line) or can be the special value zero (thin
  6733. line).
  6734.  
  6735. Wide lines are drawn centered on the path described by the
  6736. graphics request.  Unless otherwise specified by the join or
  6737. cap style, the bounding box of a wide line with endpoints
  6738. [x1, y1], [x2, y2], and width w is a rectangle with vertices
  6739. at the following real coordinates:
  6740.  
  6741.  
  6742.         [x1-(w*sn/2), y1+(w*cs/2)], [x1+(w*sn/2), y1-(w*cs/2)],
  6743.         [x2-(w*sn/2), y2+(w*cs/2)], [x2+(w*sn/2), y2-(w*cs/2)]
  6744.  
  6745. The sn is the sine of the angle of the line and cs is the
  6746. cosine of the angle of the line.  A pixel is part of the
  6747. line and, hence, is drawn, if the center of the pixel is
  6748. fully inside the bounding box (which is viewed as having
  6749. infinitely thin edges).  If the center of the pixel is
  6750. exactly on the bounding box, it is part of the line if and
  6751. only if the interior is immediately to its right (x increas-
  6752. ing direction).  Pixels with centers on a horizontal edge
  6753. are a special case and are part of the line if and only if
  6754. the interior is immediately below (y increasing direction).
  6755.  
  6756. Thin lines (zero line_width) are one pixel wide lines drawn
  6757. using an unspecified, device dependent algorithm.  There are
  6758. only two constraints on this algorithm.
  6759.  
  6760.  
  6761.  
  6762.                      December 18, 1987
  6763.  
  6764.  
  6765.  
  6766.  
  6767.  
  6768.                            - 98 -
  6769.  
  6770.  
  6771. 1.   If a line is drawn unclipped from [x1,y1] to [x2,y2]
  6772.      and if another line is drawn unclipped from
  6773.      [x1+dx,y1+dy] to [x2+dx,y2+dy], a point [x,y] is
  6774.      touched by drawing the first line if and only if the
  6775.      point [x+dx,y+dy] is touched by drawing the second
  6776.      line.
  6777.  
  6778. 2.   The effective set of points comprising a line cannot be
  6779.      affected by clipping.  That is, a point is touched in a
  6780.      clipped line if and only if the point lies inside the
  6781.      clipping region and the point would be touched by the
  6782.      line when drawn unclipped.
  6783.  
  6784. A wide line drawn from [x1,y1] to [x2,y2] always draws the
  6785. same pixels as a wide line drawn from [x2,y2] to [x1,y1],
  6786. not counting cap and join styles.  Implementors are
  6787. encouraged to make this property true for thin lines, but it
  6788. is not required.  A line_width of zero may differ from a
  6789. line_width of one in which pixels are drawn.
  6790.  
  6791. In general, drawing a thin line will be faster than drawing
  6792. a wide line of width one.  However, because of their dif-
  6793. ferent drawing algorithms, thin lines may not mix well,
  6794. aesthetically speaking, with wide lines.  If it is desirable
  6795. to obtain precise and uniform results across all displays, a
  6796. client should always use a line_width of one, rather than a
  6797. line_width of zero.
  6798.  
  6799. The line-style defines which sections of a line are drawn:
  6800.  
  6801. LineSolid
  6802.                The full path of the line is drawn.
  6803.  
  6804. LineDoub-
  6805. leDash
  6806.                The full path of the line is drawn, but the
  6807.                even dashes are filled differently than the
  6808.                odd dashes (see fill-style) with CapButt
  6809.                style used where even and odd dashes meet.
  6810.  
  6811.  
  6812.  
  6813.  
  6814. LineOnOff-
  6815. Dash
  6816.                Only the even dashes are drawn, and cap-style
  6817.                applies to all internal ends of the indivi-
  6818.                dual dashes, except CapNotLast is treated as
  6819.                CapButt.
  6820.  
  6821.  
  6822.  
  6823.  
  6824.  
  6825.  
  6826. The cap_style defines how the endpoints of a path are drawn:
  6827.  
  6828. CapNotLast
  6829.                Equivalent to CapButt, except that for a
  6830.                line_width of zero or one the final endpoint
  6831.                is not drawn.
  6832.  
  6833.  
  6834.  
  6835. CapButt
  6836.                Square at the endpoint (perpendicular to the
  6837.                slope of the line) with no projection beyond.
  6838.  
  6839.  
  6840. CapRound
  6841.                A circular arc with the diameter equal to the
  6842.                line_width, centered on the endpoint
  6843.  
  6844.  
  6845.  
  6846.  
  6847.  
  6848.  
  6849.  
  6850.                      December 18, 1987
  6851.  
  6852.  
  6853.  
  6854.  
  6855.  
  6856.                            - 99 -
  6857.  
  6858.  
  6859.                (equivalent to CapButt for line_width zero or
  6860.                one).
  6861.  
  6862.  
  6863. CapProject-
  6864. ing
  6865.                Square at the end, but the path continues
  6866.                beyond the endpoint for a distance equal to
  6867.                half the line_width (equivalent to CapButt
  6868.                for line_width zero or one).
  6869.  
  6870.  
  6871.  
  6872.  
  6873.  
  6874.  
  6875. The join_style defines how corners are drawn for wide lines:
  6876.  
  6877. JoinMiter
  6878.                The outer edges of two lines extend to meet
  6879.                at an angle.
  6880.  
  6881.  
  6882. JoinRound
  6883.                A circular arc with diameter equal to the
  6884.                line_width, centered on the joinpoint.
  6885.  
  6886.  
  6887. JoinBevel
  6888.                CapButt endpoint styles, and then the tri-
  6889.                angular notch filled.
  6890.  
  6891.  
  6892.  
  6893.  
  6894. For a line with coincident endpoints (x1=x2, y1=y2), when
  6895. the cap_style is applied to both endpoints, the semantics
  6896. depends on the line_width and the cap_style:
  6897.  
  6898. CapNotLast
  6899.                thin
  6900.                        Device dependent, but the desired effect
  6901.                        is that nothing is drawn.
  6902.  
  6903.  
  6904. CapButt
  6905.                thin
  6906.                        Device dependent, but the desired effect
  6907.                        is that a single pixel is drawn.
  6908.  
  6909.  
  6910. CapRound
  6911.                thin
  6912.                        Same as CapButt/thin.
  6913.  
  6914. CapProject-
  6915. ing
  6916.                thin
  6917.                        Same as Butt/thin.
  6918.  
  6919.  
  6920. CapButt
  6921.                wide
  6922.                        Nothing is drawn.
  6923.  
  6924. CapRound
  6925.                wide
  6926.                        The closed path is a circle, centered at
  6927.                        the endpoint, with diameter equal to the
  6928.                        line_width.
  6929.  
  6930.  
  6931.  
  6932. CapRound
  6933.                thin
  6934.                        Device dependent, but the desired effect
  6935.                        is that a single pixel is drawn
  6936.  
  6937.  
  6938. CapProject-
  6939. ing
  6940.                wide
  6941.                        The closed path is a square4, aligned
  6942.                        with the coordinate axes, centered at
  6943.                        the endpoint, with sides equal to the
  6944.                        line_width
  6945.  
  6946.  
  6947.  
  6948.  
  6949. CapProject-
  6950. ing
  6951.                thin
  6952.                        Device dependent, but the desired effect
  6953.                        is that a single pixel is drawn
  6954.  
  6955.  
  6956.  
  6957.  
  6958. For a line with coincident endpoints (x1=x2, y1=y2), when
  6959. the join_style is applied at one or both endpoints, the
  6960. effect is as if the line was removed from the overall path.
  6961. However, if the total path consists of or is reduced to a
  6962. single point joined with itself, the effect is the same as
  6963. when the cap_style is applied at both endpoints.
  6964.  
  6965.  
  6966.                      December 18, 1987
  6967.  
  6968.  
  6969.  
  6970.  
  6971.  
  6972.                           - 100 -
  6973.  
  6974.  
  6975. The tile/stipple and clip origins are interpreted relative
  6976. to the origin of whatever destination drawable is specified
  6977. in a graphics request.  The tile pixmap must have the same
  6978. root and depth as the graphics context.  Otherwise, a Bad-
  6979. Match error is generated.  The stipple pixmap must have
  6980. depth one and must have the same root as the graphics con-
  6981. text (else a BadMatch error). For stipple operations where
  6982. the fill_style is FillStippled but not FillOpaqueStippled,
  6983. the stipple pattern is tiled in a single plane and acts as
  6984. an additional clip mask to be ANDed with the clip_mask. Any
  6985. size pixmap can be used for tiling or stippling, although
  6986. some sizes may be faster to use than others.
  6987.  
  6988. The fill_style defines the contents of the source for line,
  6989. text, and fill requests. For all text and fill requests (for
  6990. example, XDrawText, XDrawText16, XFillRectangle, XFillPo-
  6991. lygon, and XFillArc); for line requests (for example, XDraw-
  6992. Line, XDrawSegments, XDrawRectangle, XDrawArc) with
  6993. line_style LineSolid; and for the even dashes for line
  6994. requests with line_style LineOnOffDash or LineDoubleDash the
  6995. following apply:
  6996.  
  6997. FillSolid
  6998.                     Foreground.
  6999.  
  7000. FillTiled
  7001.                     Tile.
  7002.  
  7003. FillOpaqueStip-
  7004. pled
  7005.                     A tile with the same width and height as
  7006.                     stipple, but with background everywhere
  7007.                     stipple has a zero and with foreground
  7008.                     everywhere stipple has a one.
  7009.  
  7010.  
  7011.  
  7012.  
  7013. FillStippled
  7014.                     Foreground masked by stipple.
  7015.  
  7016.  
  7017.  
  7018. When drawing lines with line_style LineDoubleDash, the odd
  7019. dashes are controlled by the fill_style in the following
  7020. manner:
  7021.  
  7022. FillSolid
  7023.                     Background.
  7024.  
  7025. FillTiled
  7026.                     Same as for even dashes.
  7027.  
  7028. FillOpaqueStip-
  7029. pled
  7030.                     Same as for even dashes.
  7031.  
  7032.  
  7033. FillStippled
  7034.                     Background masked by stipple.
  7035.  
  7036.  
  7037.  
  7038. Storing a pixmap in a graphics context might or might not
  7039. result in a copy being made.  If the pixmap is later used as
  7040. the destination for a graphics request, the change might or
  7041. might not be reflected in the graphics context.  If the pix-
  7042. map is used simultaneously in a graphics request both as a
  7043. destination and as a tile or stipple, the results are not
  7044. defined.
  7045.  
  7046. It is quite likely that some amount of graphics context
  7047.  
  7048.  
  7049.  
  7050.                      December 18, 1987
  7051.  
  7052.  
  7053.  
  7054.  
  7055.  
  7056.                           - 101 -
  7057.  
  7058.  
  7059. information will be cached in display hardware and that such
  7060. hardware can only cache a small number of graphics contexts.
  7061. Given the number and complexity of components, clients
  7062. should view switching between graphics contexts with nearly
  7063. identical state as significantly more expensive than making
  7064. minor changes to a single graphics context.
  7065.  
  7066. The dash_list value allowed here is actually a simplified
  7067. form of the more general patterns that can be set with XSet-
  7068. Dashes.  Specifying a value of N here is equivalent to
  7069. specifying the two element list [N, N] in XSetDashes.  The
  7070. value must be nonzero. Otherwise, a BadValue error is gen-
  7071. erated.  The meaning of dash_offset and dash_list are
  7072. explained for the XSetDashes function.
  7073.  
  7074. The clip_mask restricts writes to the destination drawable.
  7075. If a pixmap is specified as the clip_mask, it must have
  7076. depth one and have the same root as the graphics context.
  7077. Otherwise, a BadMatch error is generated.  If clip_mask is
  7078. None, the pixels are always drawn, regardless of the clip
  7079. origin.  The clip_mask can also be set with the XSetClipRec-
  7080. tangles request.  Only pixels where the clip-mask has a one
  7081. bit are drawn. Pixels are not drawn outside the area covered
  7082. by the clip_mask or where the clip_mask has a zero bit.  It
  7083. affects all graphics requests.  The clip_mask does not clip
  7084. sources.  The clip_mask origin is interpreted relative to
  7085. the origin of whatever destination drawable is specified in
  7086. a graphics request.
  7087.  
  7088. For ClipByChildren, both source and destination windows are
  7089. additionally clipped by all viewable InputOutput children.
  7090. For IncludeInferiors, neither source nor destination window
  7091. is clipped by inferiors. This will result in drawing through
  7092. subwindow boundaries.  The use of IncludeInferiors on a win-
  7093. dow of one depth with mapped inferiors of differing depth is
  7094. not illegal, but the semantics are undefined by the core
  7095. protocol.
  7096.  
  7097. The fill_rule defines what pixels are inside (drawn) for
  7098. paths given in XFillPolygon requests. EvenOddRule means a
  7099. point is inside if an infinite ray with the point as origin
  7100. crosses the path an odd number of times.
  7101.  
  7102. For WindingRule, a point is inside if an infinite ray with
  7103. the point as origin crosses an unequal number of clockwise
  7104. and counterclockwise directed path segments.  A clockwise
  7105. directed path segment is one which crosses the ray from left
  7106. to right as observed from the point.  A counterclockwise
  7107. segment is one which crosses the ray from right to left as
  7108. observed from the point.  The case where a directed line
  7109. segment is coincident with the ray is uninteresting because
  7110. you can simply choose a different ray that is not coincident
  7111. with a segment.
  7112.  
  7113.  
  7114.  
  7115.  
  7116.                      December 18, 1987
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.                           - 102 -
  7123.  
  7124.  
  7125. For both EvenOddRule and WindingRule, a point is infinitely
  7126. small, and the path is an infinitely thin line. A pixel is
  7127. inside if the center point of the pixel is inside, and the
  7128. center point is not on the boundary. If the center point is
  7129. on the boundary, the pixel is inside if and only if the
  7130. polygon interior is immediately to its right (x increasing
  7131. direction). Pixels with centers along a horizontal edge are
  7132. a special case and are inside if and only if the polygon
  7133. interior is immediately below (y increasing direction).
  7134.  
  7135. The arc_mode controls filling in the XFillArcs function and
  7136. can be one of the constants ArcPieSlice or ArcChord.  The
  7137. graphics_exposure flag controls GraphicsExpose event genera-
  7138. tion for XCopyArea and XCopyPlane requests (and any similar
  7139. requests defined by extensions).
  7140.  
  7141. The other event errors that can be generated by XCreateGC
  7142. are BadDrawable, BadPixmap, BadAlloc, BadMatch, and BadFont.
  7143.  
  7144.  
  7145. Use XCopyGC to copy components from a source graphics con-
  7146. text to a destination graphics context. The definition for
  7147. this function is:
  7148.  
  7149. XCopyGC(display, src, valuemask_copy, dest)
  7150.       Display *display;
  7151.       GC src, dest;
  7152.       unsigned long valuemask_copy;
  7153.  
  7154.  
  7155. display   Specifies the connection to the X server.
  7156.  
  7157. src       Specifies the components of the source graphics
  7158.           context.
  7159.  
  7160. valuemask_copySpecifies which components in the source
  7161.           graphics context are to be copied to the destina-
  7162.           tion graphics context.  This argument is the bit-
  7163.           wise inclusive OR of one or more of the valid GC
  7164.           component masks.
  7165.  
  7166. dest      Specifies the destination graphics context.
  7167.  
  7168. The XCopyGC function copies the specified components from
  7169. the source graphics context to the destination graphics con-
  7170. text.  The source and destination graphics contexts must
  7171. have the same root and depth.  Otherwise, a BadMatch error
  7172. is generated.  The valuemask_copy specifies which component
  7173. to copy, as for XCreateGC.
  7174.  
  7175. The other event errors that can be generated by XCopyGC are
  7176. BadGC, BadAlloc, and BadValue.
  7177.  
  7178.  
  7179.  
  7180.  
  7181.  
  7182.                      December 18, 1987
  7183.  
  7184.  
  7185.  
  7186.  
  7187.  
  7188.                           - 103 -
  7189.  
  7190.  
  7191. Use XChangeGC to change the components in the specified
  7192. graphics context. The definition for this function is:
  7193.  
  7194. XChangeGC(display, gc, valuemask_change, values)
  7195.       Display *display;
  7196.       GC gc;
  7197.       unsigned long valuemask_change;
  7198.       XGCValues *values;
  7199.  
  7200.  
  7201. display   Specifies the connection to the X server.
  7202.  
  7203. gc        Specifies the graphics context.
  7204.  
  7205. valuemask_changeSpecifies which components in the graphics
  7206.           context are to be changed using information in the
  7207.           XGCValues structure.  This argument is the bitwise
  7208.           inclusive OR of one or more of the valid GC com-
  7209.           ponent masks.
  7210.  
  7211. values    Specifies a pointer to the XGCValues structure.
  7212.  
  7213. The XChangeGC function changes the components specified by
  7214. the valuemask_change argument for the specified graphics
  7215. context.  The values argument contains the values to be set.
  7216. The values and restrictions are the same as for XCreateGC.
  7217. Changing the clip_mask also overrides any previous
  7218. XSetClipRectangles request on the context. Changing the
  7219. dash_offset or dash_list overrides any previous XSetDashes
  7220. request on the context.  The order in which components are
  7221. verified and altered is sever-dependent.  If an error is
  7222. generated, a subset of the components may have been altered.
  7223.  
  7224. The errors that can be generated by XChangeGC are BadGC,
  7225. BadPixmap, BadFont, BadMatch, BadAlloc, and BadValue.
  7226.  
  7227.  
  7228. Use XFreeGC to free the specified graphics context. The
  7229. definition for this function is:
  7230.  
  7231. XFreeGC(display, gc)
  7232.       Display *display;
  7233.       GC gc;
  7234.  
  7235.  
  7236. display   Specifies the connection to the X server.
  7237.  
  7238. gc        Specifies the graphics context.
  7239.  
  7240. The XFreeGC function destroys the specified graphics context
  7241. as well as the shadow copy.
  7242.  
  7243. The error that can be generated by XFreeGC is BadGC.
  7244.  
  7245.  
  7246.  
  7247.  
  7248.                      December 18, 1987
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.                           - 104 -
  7255.  
  7256.  
  7257. 5.4.  Using GC Convenience Routines
  7258.  
  7259. Xlib provides functions with which you can set a graphics
  7260. context component.  This section discusses how to set the:
  7261.  
  7262. o    Foreground, background, plane mask, or function com-
  7263.      ponents
  7264.  
  7265. o    Line attributes and dashes components
  7266.  
  7267. o    Fill style and fill rule components
  7268.  
  7269. o    Fill tile and stipple components
  7270.  
  7271. o    Font component
  7272.  
  7273. o    Clip region component
  7274.  
  7275. o    Arc mode, subwindow mode, and graphics exposure com-
  7276.      ponents
  7277.  
  7278. 5.4.1.  Setting Foreground, Background, Plane Mask, or Func-
  7279. tion
  7280.  
  7281. Use XSetState to set the foreground, background, plane mask,
  7282. and function components for the specified graphics context.
  7283. The definition for this function is:
  7284.  
  7285. XSetState(display, gc, foreground, background, function, plane_mask)
  7286.       Display *display;
  7287.       GC gc;
  7288.       unsigned long foreground, background;
  7289.       int function;
  7290.       unsigned long plane_mask;
  7291.  
  7292.  
  7293. display   Specifies the connection to the X server.
  7294.  
  7295. gc        Specifies the graphics context.
  7296.  
  7297. foregroundSpecifies the foreground you want to set for the
  7298.           specified graphics context.
  7299.  
  7300. backgroundSpecifies the background you want to set for the
  7301.           specified graphics context.
  7302.  
  7303. function  Specifies the function you want to set for the
  7304.           specified graphics context.
  7305.  
  7306. plane_maskSpecifies the plane mask.
  7307.  
  7308.  
  7309. The errors that can be generated by XSetState are BadGC and
  7310. BadValue.
  7311.  
  7312.  
  7313.  
  7314.                      December 18, 1987
  7315.  
  7316.  
  7317.  
  7318.  
  7319.  
  7320.                           - 105 -
  7321.  
  7322.  
  7323. Use XSetFunction to set a specified value in the specified
  7324. graphics context. The definition for this function is:
  7325.  
  7326. XSetFunction(display, gc, function)
  7327.       Display *display;
  7328.       GC gc;
  7329.       int function;
  7330.  
  7331.  
  7332. display   Specifies the connection to the X server.
  7333.  
  7334. gc        Specifies the graphics context.
  7335.  
  7336. function  Specifies the function you want to set for the
  7337.           specified graphics context.
  7338.  
  7339. The errors that can be generated by XSetFunction are BadGC
  7340. and BadValue.
  7341.  
  7342.  
  7343. Use XSetPlaneMask to set the plane mask in the specified
  7344. graphics context. The definition for this function is:
  7345.  
  7346. XSetPlaneMask(display, gc, plane_mask)
  7347.       Display *display;
  7348.       GC gc;
  7349.       unsigned long plane_mask;
  7350.  
  7351.  
  7352. display   Specifies the connection to the X server.
  7353.  
  7354. gc        Specifies the graphics context.
  7355.  
  7356. plane_maskSpecifies the plane mask.
  7357.  
  7358. The error that can be generated by XSetPlaneMask is BadGC.
  7359.  
  7360.  
  7361. Use XSetForeground to set the foreground in the specified
  7362. graphics context. The definition for this function is:
  7363.  
  7364. XSetForeground(display, gc, foreground)
  7365.       Display *display;
  7366.       GC gc;
  7367.       unsigned long foreground;
  7368.  
  7369.  
  7370. display   Specifies the connection to the X server.
  7371.  
  7372. gc        Specifies the graphics context.
  7373.  
  7374. foregroundSpecifies the foreground you want to set for the
  7375.           specified graphics context.
  7376.  
  7377.  
  7378.  
  7379.  
  7380.                      December 18, 1987
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.                           - 106 -
  7387.  
  7388.  
  7389. The error that can be generated by XSetForeground is BadGC.
  7390.  
  7391.  
  7392. Use XSetBackground to set the background in the specified
  7393. graphics context. The definition for this function is:
  7394.  
  7395. XSetBackground(display, gc, background)
  7396.       Display *display;
  7397.       GC gc;
  7398.       unsigned long background;
  7399.  
  7400.  
  7401. display   Specifies the connection to the X server.
  7402.  
  7403. gc        Specifies the graphics context.
  7404.  
  7405. backgroundSpecifies the background you want to set for the
  7406.           specified graphics context.
  7407.  
  7408. The error that can be generated by XSetBackground is BadGC.
  7409.  
  7410. 5.4.2.  Setting Line Attributes and Dashes
  7411.  
  7412. Use XSetLineAttributes to set the line drawing components in
  7413. the specified graphics context. The definition for this
  7414. function is:
  7415.  
  7416. XSetLineAttributes(display, gc, line_width, line_style, cap_style, join_style)
  7417.       Display *display;
  7418.       GC gc;
  7419.       unsigned int line_width;
  7420.       int line_style;
  7421.       int cap_style;
  7422.       int join_style;
  7423.  
  7424.  
  7425. display   Specifies the connection to the X server.
  7426.  
  7427. gc        Specifies the graphics context.
  7428.  
  7429. line_widthSpecifies the line width you want to set for the
  7430.           specified graphics context.
  7431.  
  7432. line_styleSpecifies the line style you want to set for the
  7433.           specified graphics context.  Possible values are
  7434.           LineSolid (solid), LineOnOffDash (on-off dash), or
  7435.           LineDoubleDash (double dash).
  7436.  
  7437. cap_style Specifies the line and cap style you want to set
  7438.           for the specified graphics context.  Possible
  7439.           values are CapNotLast, CapButt, CapRound, or Cap-
  7440.           Projecting.
  7441.  
  7442.  
  7443.  
  7444.  
  7445.  
  7446.                      December 18, 1987
  7447.  
  7448.  
  7449.  
  7450.  
  7451.  
  7452.                           - 107 -
  7453.  
  7454.  
  7455. join_styleSpecifies the line-join style you want to set for
  7456.           the specified graphics context.  Possible values
  7457.           are JoinMiter, JoinRound, or JoinBevel.
  7458.  
  7459. The errors that can be generated by XSetLineAttributes are
  7460. BadGC and BadValue.
  7461.  
  7462.  
  7463. Use XSetDashes to set the dash_offset and dash_list for
  7464. dashed line styles in the specified graphics context. The
  7465. definition for this function is:
  7466.  
  7467. XSetDashes(display, gc, dash_offset, dash_list, n)
  7468.         Display *display;
  7469.         GC gc;
  7470.         int dash_offset;
  7471.         char dash_list[];
  7472.         int n;
  7473.  
  7474.  
  7475. display   Specifies the connection to the X server.
  7476.  
  7477. gc        Specifies the graphics context.
  7478.  
  7479. dash_offsetSpecifies the phase of the pattern for the dashed
  7480.           line style you want to set for the specified
  7481.           graphics context.
  7482.  
  7483. dash_list Specifies the dash list for the dashed line style
  7484.           you want to set for the specified graphics con-
  7485.           text.
  7486.  
  7487. n         Specifies the length of the dash list argument.
  7488.  
  7489. The XSetDashes function sets the dash_offset and dash_list
  7490. in the specified GC for dashed line styles.  Dashes cannot
  7491. be empty. Otherwise, a BadValue error is generated.  The
  7492. initial and alternating elements of the dash_list are the
  7493. even dashes, the others are the odd dashes.  All of the ele-
  7494. ments must be nonzero.  Otherwise, a BadValue error is gen-
  7495. erated.  Specifying an odd-length list is equivalent to
  7496. specifying the same list concatenated with itself to produce
  7497. an even-length list.
  7498.  
  7499. You probably will find it easiest to specify the elements of
  7500. the dash_list as octal or hex values.  The dash_offset
  7501. defines the phase of the pattern, specifying how many ele-
  7502. ments into the dash_list the pattern should actually begin
  7503. in any single graphics request.  N specifies the length of
  7504. the dash_list.  Dashing is continuous through path elements
  7505. combined with a join_style, but is reset to the dash_offset
  7506. each time a cap_style is applied at a line endpoint.
  7507.  
  7508. The unit of measure for dashes is the same as in the
  7509.  
  7510.  
  7511.  
  7512.                      December 18, 1987
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.                           - 108 -
  7519.  
  7520.  
  7521. ordinary coordinate system.  Ideally, a dash length is meas-
  7522. ured along the slope of the line, but implementations are
  7523. only required to match this ideal for horizontal and verti-
  7524. cal lines.  Failing the ideal semantics, it is suggested
  7525. that the length be measured along the major axis of the
  7526. line.  The major axis is defined as the x axis for lines
  7527. drawn at an angle of between -45 and +45 degrees or between
  7528. 315 and 225 degrees from the x axis.  For all other lines,
  7529. the major axis is the y axis.  The default dash_list in a
  7530. newly created GC is equivalent to `` 04 04''.
  7531.  
  7532. The other event errors that can be generated by XSetDashes
  7533. are BadAlloc and BadGC.
  7534.  
  7535. 5.4.3.  Setting the Fill Style and File Rule Components
  7536.  
  7537. Use XSetFillStyle to set the fill style in the specified
  7538. graphics context. The definition for this function is:
  7539.  
  7540. XSetFillStyle(display, gc, fill_style)
  7541.       Display *display;
  7542.       GC gc;
  7543.       int fill_style;
  7544.  
  7545.  
  7546. display   Specifies the connection to the X server.
  7547.  
  7548. gc        Specifies the graphics context.
  7549.  
  7550. fill_styleSpecifies the fill style you want to set for the
  7551.           specified graphics context.  Possible values are
  7552.           FillSolid, FillTiled, FillStippled, or FillOpa-
  7553.           queStippled.
  7554.  
  7555. The errors that can be generated by XSetFillStyle are BadGC
  7556. and BadValue.
  7557.  
  7558.  
  7559. Use XSetFillRule to set the fill rule in the specified
  7560. graphics context. The definition for this function is:
  7561.  
  7562. XSetFillRule(display, gc, fill_rule)
  7563.       Display *display;
  7564.       GC gc;
  7565.       int fill_rule;
  7566.  
  7567.  
  7568. display   Specifies the connection to the X server.
  7569.  
  7570. gc        Specifies the graphics context.
  7571.  
  7572. fill_rule Specifies the fill rule you want to set for the
  7573.           specified graphics context.  You can pass one of
  7574.           these constants:  EvenOddRule or WindingRule.
  7575.  
  7576.  
  7577.  
  7578.                      December 18, 1987
  7579.  
  7580.  
  7581.  
  7582.  
  7583.  
  7584.                           - 109 -
  7585.  
  7586.  
  7587. The errors that can be generated by XSetFillRule are BadGC
  7588. and BadValue.
  7589.  
  7590. 5.4.4.  Setting the Fill Tile and Stipple Components
  7591.  
  7592. Some hardware can support specific size patterns for tiling
  7593. or stippling that runs much faster than arbitrary sizes.
  7594. Xlib provides functions with which you can determine the
  7595. best size, tile, or stipple for the display as well as set
  7596. the tile or stipple shape and the tile/stipple origin.
  7597.  
  7598.  
  7599. Use XQueryBestSize to obtain the best size.  The definition
  7600. for this function is:
  7601.  
  7602. Status XQueryBestSize(display, class, which_screen, width, height, width_return, height_return)
  7603.       Display *display;
  7604.       int class;
  7605.       Drawable which_screen;
  7606.       unsigned int width, height;
  7607.       unsigned int *width_return, *height_return;
  7608.  
  7609.  
  7610. display   Specifies the connection to the X server.
  7611.  
  7612. class     Specifies the class that you are interested in.
  7613.           You can pass one of these constants:  TileShape,
  7614.           CursorShape, or StippleShape.
  7615.  
  7616. which_screenSpecifies any drawable on a screen.
  7617.  
  7618. width
  7619. height    Specify the width and height.
  7620.  
  7621. width_return
  7622. height_returnReturns the width and height of the object best
  7623.           supported by the display hardware.
  7624.  
  7625. The XQueryBestSize function returns the best or closest size
  7626. to the specified size.  For CursorShape, this is the largest
  7627. size that can be fully displayed on the screen specified by
  7628. which_screen.  For TileShape, this is the size that can be
  7629. tiled fastest.  For StippleShape, this is the size that can
  7630. be stippled fastest.  For CursorShape, the drawable indi-
  7631. cates the desired screen.  For TileShape and StippleShape,
  7632. the drawable indicates the screen and possibly the window
  7633. class and depth.  An InputOnly window cannot be used as the
  7634. drawable for TileShape or StippleShape.  Otherwise, a Bad-
  7635. Match error is generated.
  7636.  
  7637. The other event errors that can be generated by XQueryBest-
  7638. Size are BadDrawable, BadMatch, and BadValue.
  7639.  
  7640.  
  7641.  
  7642.  
  7643.  
  7644.                      December 18, 1987
  7645.  
  7646.  
  7647.  
  7648.  
  7649.  
  7650.                           - 110 -
  7651.  
  7652.  
  7653. Use XQueryBestTile to obtain the best fill tile shape.  The
  7654. definition for this function is:
  7655.  
  7656. Status XQueryBestTile(display, which_screen, width, height, width_return, height_return)
  7657.       Display *display;
  7658.       Drawable which_screen;
  7659.       unsigned int width, height;
  7660.       unsigned int *width_return, *height_return;
  7661.  
  7662.  
  7663. display   Specifies the connection to the X server.
  7664.  
  7665. which_screenSpecifies any drawable on a screen.
  7666.  
  7667. width
  7668. height    Specify the width and height.
  7669.  
  7670. width_return
  7671. height_returnReturns the width and height of the object best
  7672.           supported by the display hardware.
  7673.  
  7674. The XQueryBestTile function returns the best or closest
  7675. size, that is, the size that can be tiled fastest on the
  7676. screen specified by which_screen.  The drawable indicates
  7677. the screen and possibly the window class and depth.  An
  7678. InputOnly window cannot be used as the drawable for XQuer-
  7679. yBestTile.  Otherwise, a BadMatch error is generated.
  7680.  
  7681. The other error that can be generated by XQueryBestTile is
  7682. BadDrawable.
  7683.  
  7684.  
  7685. Use XQueryBestStipple to obtain the best stipple shape.  The
  7686. definition for this function is:
  7687.  
  7688. Status XQueryBestStipple(display, which_screen, width, height, width_return, height_return)
  7689.       Display *display;
  7690.       Drawable which_screen;
  7691.       unsigned int width, height;
  7692.       unsigned int *width_return, *height_return;
  7693.  
  7694.  
  7695. display   Specifies the connection to the X server.
  7696.  
  7697. which_screenSpecifies any drawable on a screen.
  7698.  
  7699. width
  7700. height    Specify the width and height.
  7701.  
  7702. width_return
  7703. height_returnReturns the width and height of the object best
  7704.           supported by the display hardware.
  7705.  
  7706. The XQueryBestStipple function returns the best or closest
  7707.  
  7708.  
  7709.  
  7710.                      December 18, 1987
  7711.  
  7712.  
  7713.  
  7714.  
  7715.  
  7716.                           - 111 -
  7717.  
  7718.  
  7719. size, that is, the size that can be stippled fastest on the
  7720. screen specified by which_screen.  The drawable indicates
  7721. the screen and possibly the window class and depth.  An
  7722. InputOnly window cannot be used as the drawable for XQuer-
  7723. yBestStipple.  Otherwise, a BadMatch error is generated.
  7724.  
  7725. The other error that can be generated by XQueryBestStipple
  7726. is BadDrawable.
  7727.  
  7728.  
  7729. Use XSetTile to set the fill tile in the specified graphics
  7730. context. The definition for this function is:
  7731.  
  7732. XSetTile(display, gc, tile)
  7733.       Display *display;
  7734.       GC gc;
  7735.       Pixmap tile;
  7736.  
  7737.  
  7738. display   Specifies the connection to the X server.
  7739.  
  7740. gc        Specifies the graphics context.
  7741.  
  7742. tile      Specifies the fill tile you want to set for the
  7743.           specified graphics context.
  7744.  
  7745. The errors that can be generated by XSetTile are BadGC, Bad-
  7746. Pixmap, BadMatch, and BadAlloc.
  7747.  
  7748.  
  7749. Use XSetStipple to set the stipple in the specified graphics
  7750. context. The definition for this function is:
  7751.  
  7752. XSetStipple(display, gc, stipple)
  7753.       Display *display;
  7754.       GC gc;
  7755.       Pixmap stipple;
  7756.  
  7757.  
  7758. display   Specifies the connection to the X server.
  7759.  
  7760. gc        Specifies the graphics context.
  7761.  
  7762. stipple   Specifies the stipple you want to set for the
  7763.           specified graphics context.
  7764.  
  7765. The errors that can be generated by XSetStipple are BadGC,
  7766. BadPixmap, BadMatch, and BadAlloc.
  7767.  
  7768.  
  7769. Use XSetTSOrigin to set the tile or stipple origin in the
  7770. specified graphics context.  The definition for this func-
  7771. tion is:
  7772.  
  7773.  
  7774.  
  7775.  
  7776.                      December 18, 1987
  7777.  
  7778.  
  7779.  
  7780.  
  7781.  
  7782.                           - 112 -
  7783.  
  7784.  
  7785. XSetTSOrigin(display, gc, ts_x_origin, ts_y_origin)
  7786.       Display *display;
  7787.       GC gc;
  7788.       int ts_x_origin, ts_y_origin;
  7789.  
  7790.  
  7791. display   Specifies the connection to the X server.
  7792.  
  7793. gc        Specifies the graphics context.
  7794.  
  7795. ts_x_origin
  7796. ts_y_originSpecify the x and y coordinates of the tile or
  7797.           stipple origin.
  7798.  
  7799. The error that can be generated by XSetTSOrigin is BadGC.
  7800.  
  7801. 5.4.5.  Setting the Current Font
  7802.  
  7803. Use XSetFont to set the current font in the specified graph-
  7804. ics context. The definition for this function is:
  7805.  
  7806. XSetFont(display, gc, font)
  7807.       Display *display;
  7808.       GC gc;
  7809.       Font font;
  7810.  
  7811.  
  7812. display   Specifies the connection to the X server.
  7813.  
  7814. gc        Specifies the graphics context.
  7815.  
  7816. font      Specifies the font ID.
  7817.  
  7818. The errors that can be generated by XSetFont are BadGC, Bad-
  7819. Font, and BadAlloc.
  7820.  
  7821. 5.4.6.  Setting Clip Region
  7822.  
  7823. Xlib provides functions with which you can set the clip ori-
  7824. gin or the clip mask as well as with which you can set the
  7825. clip mask to a list of rectangles.
  7826.  
  7827.  
  7828. Use XSetClipOrigin to set the clip origin in the specified
  7829. graphics context. The definition for this function is:
  7830.  
  7831. XSetClipOrigin(display, gc, clip_x_origin, clip_y_origin)
  7832.       Display *display;
  7833.       GC gc;
  7834.       int clip_x_origin, clip_y_origin;
  7835.  
  7836.  
  7837.  
  7838.  
  7839.  
  7840.  
  7841.  
  7842.                      December 18, 1987
  7843.  
  7844.  
  7845.  
  7846.  
  7847.  
  7848.                           - 113 -
  7849.  
  7850.  
  7851. display   Specifies the connection to the X server.
  7852.  
  7853. gc        Specifies the graphics context.
  7854.  
  7855. clip_x_origin
  7856. clip_y_originSpecify the x and y coordinates of the clip
  7857.           origin.
  7858.  
  7859. The error that can be generated by XSetClipOrigin is BadGC.
  7860.  
  7861.  
  7862. Use XSetClipMask to set the clip_mask in the specified
  7863. graphics context to the specified pixmap. The definition for
  7864. this function is:
  7865.  
  7866. XSetClipMask(display, gc, pixmap)
  7867.       Display *display;
  7868.       GC gc;
  7869.       Pixmap pixmap;
  7870.  
  7871.  
  7872. display   Specifies the connection to the X server.
  7873.  
  7874. gc        Specifies the graphics context.
  7875.  
  7876. pixmap    Specifies the pixmap.
  7877.  
  7878. The errors that can be generated by XSetClipMask are BadGC,
  7879. BadMatch, and BadValue.
  7880.  
  7881.  
  7882. Use XSetClipRectangles to change the clip_mask in the speci-
  7883. fied graphics context to the specified list of rectangles.
  7884. The definition for this function is:
  7885.  
  7886. XSetClipRectangles(display, gc, clip_x_origin, clip_y_origin, rectangles, n, ordering)
  7887.       Display *display;
  7888.       GC gc;
  7889.       int clip_x_origin, clip_y_origin;
  7890.       XRectangle rectangles[];
  7891.       int n;
  7892.       int ordering;
  7893.  
  7894.  
  7895. display   Specifies the connection to the X server.
  7896.  
  7897. gc        Specifies the graphics context.
  7898.  
  7899. clip_x_origin
  7900. clip_y_originSpecify the x and y coordinates of the clip
  7901.           origin.
  7902.  
  7903.  
  7904.  
  7905.  
  7906.  
  7907.  
  7908.                      December 18, 1987
  7909.  
  7910.  
  7911.  
  7912.  
  7913.  
  7914.                           - 114 -
  7915.  
  7916.  
  7917. rectanglesSpecifies an array of rectangles.  These are the
  7918.           rectangles you want to specify in the graphics
  7919.           context.
  7920.  
  7921. n         Specifies the number of rectangles.
  7922.  
  7923. ordering  Specifies the ordering relations on the rectan-
  7924.           gles.  Possible values are Unsorted, YSorted,
  7925.           YXSorted, or YXBanded.
  7926.  
  7927. The XSetClipRectangles function changes the clip_mask in the
  7928. specified graphics context to the specified list of rectan-
  7929. gles and sets the clip origin.  The output is clipped to
  7930. remain contained within the rectangles.  The number of rec-
  7931. tangles are specified with the n argument. The clip origin
  7932. is interpreted relative to the origin of whatever destina-
  7933. tion drawable is specified in a graphics request. The rec-
  7934. tangle coordinates are interpreted relative to the clip ori-
  7935. gin. The rectangles should be nonintersecting, or the graph-
  7936. ics results will be undefined.  Note that the list of rec-
  7937. tangles can be empty, which effectively disables output.
  7938. This is the opposite of passing None as the clip_mask in
  7939. XCreateGC and XChangeGC.
  7940.  
  7941. If known by the client, ordering relations on the rectangles
  7942. can be specified with the ordering argument. This may pro-
  7943. vide faster operation by the server. If an incorrect order-
  7944. ing is specified, the X server may generate a BadMatch
  7945. error, but it is not required to do so.  If no error is gen-
  7946. erated, the graphics results are undefined.  Unsorted means
  7947. the rectangles are in arbitrary order.  YSorted means that
  7948. the rectangles are nondecreasing in their Y origin.
  7949. YXSorted additionally constrains YSorted order in that all
  7950. rectangles with an equal Y origin are nondecreasing in their
  7951. X origin. YXBanded additionally constrains YXSorted by
  7952. requiring that, for every possible Y scan line, all rectan-
  7953. gles that include that scan line have an identical Y origins
  7954. and Y extents.
  7955.  
  7956. The other event errors that can be generated by XSetClipRec-
  7957. tangles are BadGC, BadAlloc, and BadValue.
  7958.  
  7959.                             Note
  7960.  
  7961.      The Xlib library provides a set of basic functions
  7962.      for performing region arithmetic.  For information
  7963.      about these functions, see Chapter 10.
  7964.  
  7965.  
  7966. 5.4.7.  Setting the Arc Mode, Subwindow Mode, and Graphics
  7967. Exposure components
  7968.  
  7969. Use XSetArcMode to set the arc mode in the specified graph-
  7970. ics context. The definition for this function is:
  7971.  
  7972.  
  7973.  
  7974.                      December 18, 1987
  7975.  
  7976.  
  7977.  
  7978.  
  7979.  
  7980.                           - 115 -
  7981.  
  7982.  
  7983. XSetArcMode(display, gc, arc_mode)
  7984.       Display *display;
  7985.       GC gc;
  7986.       int arc_mode;
  7987.  
  7988.  
  7989. display   Specifies the connection to the X server.
  7990.  
  7991. gc        Specifies the graphics context.
  7992.  
  7993. arc_mode  Specifies the arc mode:  ArcChord specifies that
  7994.           arcs will be chord filled, while ArcPieSlice
  7995.           specifies that arcs will be pie slice filled.
  7996.  
  7997. The errors that can be generated by XSetArcMode are BadGC
  7998. and BadValue.
  7999.  
  8000.  
  8001. Use XSetSubwindowMode to set the subwindow mode in the
  8002. specified graphics context. The definition for this function
  8003. is:
  8004.  
  8005. XSetSubwindowMode(display, gc, subwindow_mode)
  8006.       Display *display;
  8007.       GC gc;
  8008.       int subwindow_mode;
  8009.  
  8010.  
  8011. display   Specifies the connection to the X server.
  8012.  
  8013. gc        Specifies the graphics context.
  8014.  
  8015. subwindow_modeSpecifies the subwindow mode:  ClipByChildren
  8016.           clips source and destination by all viewable chil-
  8017.           dren, while IncludeInferiors draws through all
  8018.           subwindows, that is, does not clip by inferiors.
  8019.  
  8020. The errors that can be generated by XSetSubwindowMode are
  8021. BadGC and BadValue.
  8022.  
  8023.  
  8024. Use XSetGraphicsExposures to set the graphics-exposures flag
  8025. in the specified graphics context. The definition for this
  8026. function is:
  8027.  
  8028. XSetGraphicsExposures(display, gc, graphics_exposures)
  8029.       Display *display;
  8030.       GC gc;
  8031.       Boolean graphics_exposures;
  8032.  
  8033.  
  8034. display   Specifies the connection to the X server.
  8035.  
  8036.  
  8037.  
  8038.  
  8039.  
  8040.                      December 18, 1987
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.                           - 116 -
  8047.  
  8048.  
  8049. gc        Specifies the graphics context.
  8050.  
  8051. graphics_exposuresSpecifies whether you want GraphicsExpose
  8052.           events to be reported when calling XCopyArea and
  8053.           XCopyPlane with this graphics context.  If True,
  8054.           GraphicsExpose events are reported.  If False,
  8055.           GraphicsExpose events are not reported.
  8056.  
  8057. The errors that can be generated by XSetGraphicsExposures
  8058. are BadGC and BadValue.
  8059.  
  8060.  
  8061.  
  8062.  
  8063.  
  8064.  
  8065.  
  8066.  
  8067.  
  8068.  
  8069.  
  8070.  
  8071.  
  8072.  
  8073.  
  8074.  
  8075.  
  8076.  
  8077.  
  8078.  
  8079.  
  8080.  
  8081.  
  8082.  
  8083.  
  8084.  
  8085.  
  8086.  
  8087.  
  8088.  
  8089.  
  8090.  
  8091.  
  8092.  
  8093.  
  8094.  
  8095.  
  8096.  
  8097.  
  8098.  
  8099.  
  8100.  
  8101.  
  8102.  
  8103.  
  8104.  
  8105.  
  8106.                      December 18, 1987
  8107.  
  8108.  
  8109.  
  8110.  
  8111.  
  8112.                           - 117 -
  8113.  
  8114.  
  8115.  
  8116.  
  8117.                          Chapter 6
  8118.  
  8119.                      Graphics Functions
  8120.  
  8121.  
  8122.  
  8123. Chapter 6 - Graphics Functions Once you have connected the
  8124. display to the X server, you can use the Xlib graphics func-
  8125. tions to:
  8126.  
  8127. o    Clear and copy areas
  8128.  
  8129. o    Draw points, lines, rectangles, and arcs
  8130.  
  8131. o    Fill areas
  8132.  
  8133. o    Manipulate fonts
  8134.  
  8135. o    Draw text characters
  8136.  
  8137. o    Transfer images between clients and server
  8138.  
  8139. o    Manipulate cursors
  8140.  
  8141.                             Note
  8142.  
  8143.      It is generally more efficient to call those
  8144.      graphics functions that take an array of arguments
  8145.      (for example, XDrawPoints) once than it is to call
  8146.      those graphics functions that do not (for example,
  8147.      XDrawPoint) a number of times.
  8148.  
  8149.  
  8150. 6.1.  Clearing Areas
  8151.  
  8152. Xlib provides functions with which you can clear an area or
  8153. the entire drawable.  Because pixmaps do not have defined
  8154. backgrounds, they cannot be filled by using the functions
  8155. described in this section.  Instead, to accomplish an analo-
  8156. gous operation on a pixmap, you should use XFillRectangle,
  8157. which sets the pixmap to a known value.  See Section 6.4.1
  8158. for information on XFillRectangle.
  8159.  
  8160.  
  8161. Use XClearArea to clear a specified rectangular area in the
  8162. specified window.  The definition for this function is:
  8163.  
  8164.  
  8165.  
  8166.  
  8167.  
  8168.  
  8169.  
  8170.  
  8171.  
  8172.                      December 18, 1987
  8173.  
  8174.  
  8175.  
  8176.  
  8177.  
  8178.                           - 118 -
  8179.  
  8180.  
  8181. XClearArea(display, w, x, y, width, height, exposures)
  8182.       Display *display;
  8183.       Window w;
  8184.       int x, y;
  8185.       unsigned int width, height;
  8186.       Bool exposures;
  8187.  
  8188.  
  8189. display   Specifies the connection to the X server.
  8190.  
  8191. w         Specifies the window ID.
  8192.  
  8193. x
  8194. y         Specify the x and y coordinates.  These coordi-
  8195.           nates are relative to the origin of the window and
  8196.           specify the upper left corner of the rectangle.
  8197.  
  8198. width
  8199. height    Specify the width and height.  These are the
  8200.           dimensions of the rectangle to be cleared.
  8201.  
  8202. exposures Specifies a boolean value of True or False.
  8203.  
  8204. The XClearArea function clears a rectangular area in the
  8205. specified window according to the specified dimensions.  If
  8206. width is zero, it is replaced with the current width of the
  8207. window minus x.  If height is zero, it is replaced with the
  8208. current height of the window minus y.  If the window has a
  8209. defined background tile, the rectangle is filled with this
  8210. tile.  If the window has background None, the contents of
  8211. the window are not changed. In either case, if exposures is
  8212. True, one or more exposure events are generated for regions
  8213. of the rectangle that are either visible or are being
  8214. retained in a backing store.  A BadMatch error is generated
  8215. if you specify a window whose class is InputOnly.
  8216.  
  8217. The other event errors that can be generated by XClearArea
  8218. are BadWindow, BadMatch, and BadValue.
  8219.  
  8220.  
  8221. Use XClearWindow to clear the entire area in the specified
  8222. window.  The definition for this function is:
  8223.  
  8224. XClearWindow(display, w)
  8225.       Display *display;
  8226.       Window w;
  8227.  
  8228.  
  8229. display   Specifies the connection to the X server.
  8230.  
  8231. w         Specifies the window ID.
  8232.  
  8233. The XClearWindow function clears the entire area in the
  8234. specified window and is equivalent to XClearArea (display,
  8235.  
  8236.  
  8237.  
  8238.                      December 18, 1987
  8239.  
  8240.  
  8241.  
  8242.  
  8243.  
  8244.                           - 119 -
  8245.  
  8246.  
  8247. w, 0, 0, 0, 0, False).  If the window has a defined back-
  8248. ground tile, the rectangle is tiled with a plane-mask of all
  8249. ones and function of GXcopy.  If the window has background
  8250. None, the contents of the window are not changed. In either
  8251. case, if exposures is True, one or more exposure events are
  8252. generated for regions of the rectangle that are either visi-
  8253. ble or are being retained in a backing store.  A BadMatch
  8254. error is generated if you specify a window whose class is
  8255. InputOnly.
  8256.  
  8257. The other event errors that can be generated by XClearWindow
  8258. are BadWindow, BadMatch, and BadValue.
  8259.  
  8260. 6.2.  Copying Areas
  8261.  
  8262. Xlib provides functions with which you can copy an area or a
  8263. bit-plane.
  8264.  
  8265.  
  8266. Use XCopyArea to copy an area of the specified drawable
  8267. between drawables of the same root and depth.  The defini-
  8268. tion for this function is:
  8269.  
  8270. XCopyArea(display, src, dest, gc, src_x, src_y, width, height,  dest_x, dest_y)
  8271.       Display *display;
  8272.       Drawable src, dest;
  8273.       GC gc;
  8274.       int src_x, src_y;
  8275.       unsigned int width, height;
  8276.       int dest_x, dest_y;
  8277.  
  8278.  
  8279. display   Specifies the connection to the X server.
  8280.  
  8281. src
  8282. dest      Specify the source and destination rectangles to
  8283.           be combined.
  8284.  
  8285. gc        Specifies the graphics context.
  8286.  
  8287. src_x
  8288. src_y     Specify the x and y coordinates of the source rec-
  8289.           tangle relative to its origin.  These coordinates
  8290.           specify the upper left corner of the source rec-
  8291.           tangle.
  8292.  
  8293. width
  8294. height    Specify the width and height.  These are the
  8295.           dimensions of both the source and destination rec-
  8296.           tangles.
  8297.  
  8298. dest_x
  8299.  
  8300.  
  8301.  
  8302.  
  8303.  
  8304.                      December 18, 1987
  8305.  
  8306.  
  8307.  
  8308.  
  8309.  
  8310.                           - 120 -
  8311.  
  8312.  
  8313. dest_y    Specify the x and y coordinates of the destination
  8314.           rectangle relative to its origin.  These coordi-
  8315.           nates specify the upper left corner of the desti-
  8316.           nation rectangle.
  8317.  
  8318. The XCopyArea function combines the specified rectangle of
  8319. src with the specified rectangle of dest.  The rectangles
  8320. specified by these two arguments must have the same root and
  8321. depth.  Otherwise, a BadMatch error is generated.  XCopyArea
  8322. uses these graphics context components: function,
  8323. plane_mask, subwindow_mode, graphics_exposures,
  8324. clip_x_origin, clip_y_origin, and clip_mask.
  8325.  
  8326. If either the regions of the source rectangle are obscured
  8327. and have not been retained in backing_store or the regions
  8328. outside the boundaries of the source drawable are specified,
  8329. those regions are not copied. Instead, the following occurs
  8330. on all corresponding destination regions that are either
  8331. visible or are retained in backing_store. If the destination
  8332. rectangle is a window with a background other than None,
  8333. these corresponding regions of the destination are tiled
  8334. (with plane_mask of all ones and function GXcopy) with that
  8335. background.  Regardless of tiling or whether the destination
  8336. is a window or a pixmap, if graphics_exposures in GC is
  8337. True, then GraphicsExpose events for all corresponding des-
  8338. tination regions are generated.  If graphics_exposures is
  8339. True but no regions are exposed, a NoExpose event is gen-
  8340. erated.  Note that by default, graphics_exposures is True on
  8341. in new GCs.  See Chapter 8 for further information.
  8342.  
  8343. The errors that can be generated by XCopyArea are BadDraw-
  8344. able, BadGC, and BadMatch.
  8345.  
  8346.  
  8347. Use XCopyPlane to copy a single bit-plane of the specified
  8348. drawable.  The drawable may have different depths.  The
  8349. definition for XCopyPlane is:
  8350.  
  8351. XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y, plane)
  8352.       Display *display;
  8353.       Drawable src, dest;
  8354.       GC gc;
  8355.       int src_x, src_y;
  8356.       unsigned int width, height;
  8357.       int dest_x, dest_y;
  8358.       unsigned long plane;
  8359.  
  8360.  
  8361. display   Specifies the connection to the X server.
  8362.  
  8363. src
  8364. dest      Specify the source and destination rectangles to
  8365.           be combined.
  8366.  
  8367.  
  8368.  
  8369.  
  8370.                      December 18, 1987
  8371.  
  8372.  
  8373.  
  8374.  
  8375.  
  8376.                           - 121 -
  8377.  
  8378.  
  8379. gc        Specifies the graphics context.
  8380.  
  8381. src_x
  8382. src_y     Specify the x and y coordinates of the source rec-
  8383.           tangle relative to its origin.  These coordinates
  8384.           specify the upper left corner of the source rec-
  8385.           tangle.
  8386.  
  8387. width
  8388. height    Specify the width and height.  These are the
  8389.           dimensions of both the source and destination rec-
  8390.           tangles.
  8391.  
  8392. dest_x
  8393. dest_y    Specify the x and y coordinates of the destination
  8394.           rectangle relative to its origin.  These coordi-
  8395.           nates specify the upper left corner of the desti-
  8396.           nation rectangle.
  8397.  
  8398. plane     Specifies the bit-plane.  You must set exactly one
  8399.           bit.
  8400.  
  8401. The XCopyPlane function combines a single bit plane of the
  8402. specified rectangle of src with the specified rectangle of
  8403. dest.  The rectangles specified by these two arguments must
  8404. have the same root but need not have the same depth.  If the
  8405. rectangles do not have the same root, a BadMatch error is
  8406. generated.  This function is identical to XCopyArea, except
  8407. that only one bit-plane is copied.  If the bit-plane does
  8408. not have exactly one bit set, a BadValue error is generated.
  8409.  
  8410. Effectively, the function forms a pixmap of the same depth
  8411. as the rectangle of dest and with a size specified by the
  8412. source region. The function uses the foreground/background
  8413. pixels in the graphics context (foreground everywhere the
  8414. bit-plane in src contains a one bit, background everywhere
  8415. the bit-plane in src contains a zero bit) and the equivalent
  8416. of a XCopyArea request is performed with all the same expo-
  8417. sure semantics.  This can also be thought of as using the
  8418. specified region of the source bit-plane as a stipple with a
  8419. fill_style of FillOpaqueStippled for filling a rectangular
  8420. area of the destination.
  8421.  
  8422. Regardless of tiling or whether the destination is a window
  8423. or a pixmap, if graphics_exposures in GC is True, the Gra-
  8424. phicsExpose events for all corresponding destination regions
  8425. are generated.  If graphics_exposures is True but no regions
  8426. are exposed, a NoExpose event is generated.  Note that by
  8427. default, graphics_exposures is True on in new GCs.  See
  8428. Chapter 8 for further information.
  8429.  
  8430. XCopyPlane uses these graphics context components: function,
  8431. plane_mask, foreground, background, subwindow_mode,
  8432. graphics_exposures, clip_x_origin, clip_y_origin, and
  8433.  
  8434.  
  8435.  
  8436.                      December 18, 1987
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.                           - 122 -
  8443.  
  8444.  
  8445. clip_mask.
  8446.  
  8447. The other event errors that can be generated by XCopyPlane
  8448. are BadDrawable, BadMatch, BadValue, and BadGC.
  8449.  
  8450. 6.3.  Drawing Points, Lines, Rectangles, and Arcs
  8451.  
  8452. Xlib provides functions with which you can draw:
  8453.  
  8454. o    A single point or multiple points
  8455.  
  8456. o    A single line or multiple lines
  8457.  
  8458. o    A single rectangle or multiple rectangles
  8459.  
  8460. o    A single arc or multiple arcs
  8461.  
  8462. Some of the functions described in the following subsections
  8463. use these structures:
  8464.  
  8465. typedef struct {
  8466.     short x1, y1, x2, y2;
  8467.     } XSegment;
  8468.  
  8469. typedef struct {
  8470.     short x, y;
  8471.     } XPoint;
  8472.  
  8473. typedef struct {
  8474.     short x, y;
  8475.     unsigned short width, height;
  8476.     } XRectangle;
  8477.  
  8478. typedef struct {
  8479.     short x, y;
  8480.     unsigned short width, height;
  8481.     short angle1, angle2;             /* Degrees * 64 */
  8482.     } XArc;
  8483.  
  8484.  
  8485. All x and y members are signed integers.  The width and
  8486. height members are 16-bit unsigned integers.  Applications
  8487. should be careful not to generate coordinates and sizes out
  8488. of the 16-bit ranges, as the protocol only has 16 bit fields
  8489. for these values.
  8490.  
  8491. 6.3.1.  Drawing Single and Multiple Points
  8492.  
  8493. Use XDrawPoint to draw a single point or XDrawPoints to draw
  8494. multiple points in the specified drawable.
  8495.  
  8496. The definition for XDrawPoint is:
  8497.  
  8498.  
  8499.  
  8500.  
  8501.  
  8502.                      December 18, 1987
  8503.  
  8504.  
  8505.  
  8506.  
  8507.  
  8508.                           - 123 -
  8509.  
  8510.  
  8511. XDrawPoint(display, d, gc, x, y)
  8512.       Display *display;
  8513.       Drawable d;
  8514.       GC gc;
  8515.       int x, y;
  8516.  
  8517.  
  8518. display   Specifies the connection to the X server.
  8519.  
  8520. d         Specifies the drawable.
  8521.  
  8522. gc        Specifies the graphics context.
  8523.  
  8524. x
  8525. y         Specify the x and y coordinates where you want the
  8526.           point drawn.
  8527.  
  8528.  
  8529. The definition for XDrawPoints is:
  8530.  
  8531. XDrawPoints(display, d, gc, points, npoints, mode)
  8532.       Display *display;
  8533.       Drawable d;
  8534.       GC gc;
  8535.       XPoint *points;
  8536.       int npoints;
  8537.       int mode;
  8538.  
  8539.  
  8540. display   Specifies the connection to the X server.
  8541.  
  8542. d         Specifies the drawable.
  8543.  
  8544. gc        Specifies the graphics context.
  8545.  
  8546. points    Specifies a pointer to an array of points.
  8547.  
  8548. npoints   Specifies the number of points in the array.
  8549.  
  8550. mode      Specifies the coordinate mode. CoordModeOrigin
  8551.           treats a coordinates as related to the origin,
  8552.           while CoordModePrevious treates all coordinates
  8553.           after the first as relative to the previous point.
  8554.  
  8555. The XDrawPoint and XDrawPoints functions use these graphics
  8556. context components: function, plane_mask, foreground,
  8557. subwindow_mode, clip_x_origin, clip_y_origin, and clip_mask.
  8558. The XDrawPoint function uses the foreground pixel and func-
  8559. tion components of the graphics context to draw a single
  8560. point into the specified drawable, while XDrawPoints draws
  8561. multiple points into the specified drawable.  These func-
  8562. tions are not affected by the tile or stipple in the graph-
  8563. ics context.
  8564.  
  8565.  
  8566.  
  8567.  
  8568.                      December 18, 1987
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.                           - 124 -
  8575.  
  8576.  
  8577. When using XDrawPoint, you simply specify the x and y coor-
  8578. dinates where you want the point drawn.  For XDrawPoints,
  8579. you specify an array of XPoint structures, each of which
  8580. contains an x and y coordinate.  XDrawPoints draws the
  8581. points in the order listed in the array.
  8582.  
  8583. XDrawPoints requires a mode argument that indicates whether
  8584. the points are relative to the drawable's origin or to the
  8585. previous point:
  8586.  
  8587. o    If mode is CoordModeOrigin, all points after the first
  8588.      are relative to the drawable's origin. (The first point
  8589.      is always relative to the drawable's origin.)
  8590.  
  8591. o    If mode is CoordModePrevious, all points after the
  8592.      first are relative to the previous point.
  8593.  
  8594. The errors that can be generated by XDrawPoint are BadDraw-
  8595. able, BadGC, and BadMatch.  The errors that can be generated
  8596. by XDrawPoint are BadDrawable, BadGC, BadValue, and Bad-
  8597. Match.
  8598.  
  8599. 6.3.2.  Drawing Single and Multiple Lines
  8600.  
  8601. Use XDrawLine to draw a single line between two points in
  8602. the specified drawable, XDrawLines to draw multiple lines in
  8603. the specified drawable, or XDrawSegments to draw multiple,
  8604. but not necessarily connected lines in the specified draw-
  8605. able.
  8606.  
  8607. The definition for XDrawLine is:
  8608.  
  8609. XDrawLine(display, d, gc, x1, y1, x2, y2)
  8610.       Display *display;
  8611.       Drawable d;
  8612.       GC gc;
  8613.       int x1, y1, x2, y2;
  8614.  
  8615.  
  8616. display   Specifies the connection to the X server.
  8617.  
  8618. d         Specifies the drawable.
  8619.  
  8620. gc        Specifies the graphics context.
  8621.  
  8622. x1
  8623. y1
  8624. x2
  8625. y2        Specify the points used to connect the line.
  8626.           Thus, XDrawLine draws a line connecting point x1,
  8627.           y1 to point x2, y2.
  8628.  
  8629.  
  8630. The definition for XDrawLines is:
  8631.  
  8632.  
  8633.  
  8634.                      December 18, 1987
  8635.  
  8636.  
  8637.  
  8638.  
  8639.  
  8640.                           - 125 -
  8641.  
  8642.  
  8643. XDrawLines(display, d, gc, points, npoints, mode)
  8644.       Display *display;
  8645.       Drawable d;
  8646.       GC gc;
  8647.       XPoint *points;
  8648.       int npoints;
  8649.       int mode;
  8650.  
  8651.  
  8652. display   Specifies the connection to the X server.
  8653.  
  8654. d         Specifies the drawable.
  8655.  
  8656. gc        Specifies the graphics context.
  8657.  
  8658. points    Specifies a pointer to an array of points.
  8659.  
  8660. npoints   Specifies the number of points in the array.
  8661.  
  8662. mode      Specifies the coordinate mode. CoordModeOrigin
  8663.           treats a coordinates as related to the origin,
  8664.           while CoordModePrevious treates all coordinates
  8665.           after the first as relative to the previous point.
  8666.  
  8667.  
  8668. The definition for XDrawSegments is:
  8669.  
  8670. XDrawSegments(display, d, gc, segments, nsegments)
  8671.       Display *display;
  8672.       Drawable d;
  8673.       GC gc;
  8674.       XSegment *segments;
  8675.       int nsegments;
  8676.  
  8677.  
  8678. display   Specifies the connection to the X server.
  8679.  
  8680. d         Specifies the drawable.
  8681.  
  8682. gc        Specifies the graphics context.
  8683.  
  8684. segments  Specifies a pointer to an array of segments.
  8685.  
  8686. nsegments Specifies the number of segments in the array.
  8687.  
  8688. The XDrawLine function uses the components of the specified
  8689. graphics context to draw a line between the specified set of
  8690. points (x1, y1 and x2, y2).  No joining is performed at
  8691. coincident end points.  For any given line, no pixel is
  8692. drawn more than once.  If lines intersect, the intersecting
  8693. pixels are drawn multiple times.
  8694.  
  8695. The XDrawLines function uses the components of the specified
  8696. graphics context to draw npoints-1 lines between each pair
  8697.  
  8698.  
  8699.  
  8700.                      December 18, 1987
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.                           - 126 -
  8707.  
  8708.  
  8709. of points (point[i], point[i+1]) in the array of XPoint
  8710. structures.  The lines are drawn in the order listed in the
  8711. array.  The lines join correctly at all intermediate points,
  8712. and if the first and last points coincide, the first and
  8713. last lines also join correctly.  For any given line, no
  8714. pixel is drawn more than once.  If thin (zero line width)
  8715. lines intersect, the intersecting pixels will be drawn mul-
  8716. tiple times.  If wide lines intersect, the intersecting pix-
  8717. els are drawn only once, as though the entire PolyLine were
  8718. a single filled shape.  XDrawLines requires a mode argument
  8719. to determine whether the points are relative to the
  8720. drawable's origin or to the previous point:
  8721.  
  8722. o    If mode is CoordModeOrigin, all points after the first
  8723.      are relative to the drawable's origin.  (The first
  8724.      point is always relative to the drawable's origin.)
  8725.  
  8726. o    If mode is CoordModePrevious, all points after the
  8727.      first are relative to the previous point.
  8728.  
  8729. The XDrawSegments function draws multiple, but not neces-
  8730. sarily connected lines. For each segment, XDrawSegments
  8731. draws a line between (x1, y1) and (x2, y2).  The lines are
  8732. drawn in the order listed in the array of XSegment struc-
  8733. tures. No joining is performed at coincident end points.
  8734. For any given line, no pixel is drawn more than once. If
  8735. lines intersect, the intersecting pixels are drawn multiple
  8736. times.
  8737.  
  8738. All three functions use these graphics context components:
  8739. function, plane_mask, line_width, line_style, cap_style,
  8740. fill_style, subwindow_mode, clip_x_origin, clip_y_origin,
  8741. and clip_mask.  The XDrawLines function also uses the
  8742. join_style graphics context component.  Additionally, all
  8743. three functions use these graphics context mode-dependent
  8744. components:  foreground, background, tile, stipple,
  8745. ts_x_origin, ts_y_origin, dash_offset, and dash_list.  See
  8746. the general discussion under XCreateGC in Chapter 5.
  8747.  
  8748. The errors that can be generated by XDrawLine, XDrawLines,
  8749. and XDrawSegments are BadDrawable, BadGC, and BadMatch.
  8750. XDrawLines can also return BadValue.
  8751.  
  8752. 6.3.3.  Drawing Single and Multiple Rectangles
  8753.  
  8754. Use XDrawRectangle to draw the outline of a single rectangle
  8755. or XDrawRectangles to draw the outline of multiple rectan-
  8756. gles in the specified drawable.
  8757.  
  8758. The definition for XDrawRectangle is:
  8759.  
  8760.  
  8761.  
  8762.  
  8763.  
  8764.  
  8765.  
  8766.                      December 18, 1987
  8767.  
  8768.  
  8769.  
  8770.  
  8771.  
  8772.                           - 127 -
  8773.  
  8774.  
  8775. XDrawRectangle(display, d, gc, x, y, width, height)
  8776.       Display *display;
  8777.       Drawable d;
  8778.       GC gc;
  8779.       int x, y;
  8780.       unsigned int width, height;
  8781.  
  8782.  
  8783. display   Specifies the connection to the X server.
  8784.  
  8785. d         Specifies the drawable.
  8786.  
  8787. gc        Specifies the graphics context.
  8788.  
  8789. x
  8790. y         Specify the x and y coordinates that define the
  8791.           upper left corner of the rectangle.
  8792.  
  8793. width
  8794. height    Specify the width and height that define the out-
  8795.           line of the rectangle.
  8796.  
  8797.  
  8798. The definition for XDrawRectangles is:
  8799.  
  8800. XDrawRectangles(display, d, gc, rectangles, nrectangles)
  8801.       Display *display;
  8802.       Drawable d;
  8803.       GC gc;
  8804.       XRectangle rectangles[];
  8805.       int nrectangles;
  8806.  
  8807.  
  8808. display   Specifies the connection to the X server.
  8809.  
  8810. d         Specifies the drawable.
  8811.  
  8812. gc        Specifies the graphics context.
  8813.  
  8814. rectanglesSpecifies a pointer to an array of rectangles.
  8815.  
  8816. nrectanglesSpecifies the number of rectangles in the array.
  8817.  
  8818. The XDrawRectangle and XDrawRectangles functions draw the
  8819. outlines of the specified rectangle or rectangles as if a
  8820. five-point PolyLine were specified for each rectangle:
  8821.  
  8822.      [x,y,] [x+width,y] [x+width,y+height] [x,y+height]
  8823.      [x,y]
  8824.  
  8825. For the specified rectangle or rectangles, no pixel is drawn
  8826. more than once.  The x and y coordinates of each rectangle
  8827. are relative to the drawable's origin and define the upper
  8828. left corner of the rectangle. XDrawRectangles draws the
  8829.  
  8830.  
  8831.  
  8832.                      December 18, 1987
  8833.  
  8834.  
  8835.  
  8836.  
  8837.  
  8838.                           - 128 -
  8839.  
  8840.  
  8841. rectangles in the order listed in the array.  If rectangles
  8842. intersect, the intersecting pixels are drawn multiple times.
  8843.  
  8844. XDrawRectangle and XDrawRectangles use these graphics con-
  8845. text components: function, plane_mask, line_width,
  8846. line_style, join_style, fill_style, subwindow_mode,
  8847. clip_x_origin, clip_y_origin, and clip_mask.  Both functions
  8848. also use these graphics context mode-dependent components:
  8849. foreground, background, tile, stipple, ts_x_origin,
  8850. ts_y_origin, dash_offset, and dash_list.  See the general
  8851. discussion under XCreateGC in Chapter 5.
  8852.  
  8853. The errors that can be generated by XDrawRectangle and
  8854. XDrawRectangles are BadDrawable, BadGC, and BadMatch.
  8855.  
  8856. 6.3.4.  Drawing Single and Multiple Arcs
  8857.  
  8858. Use XDrawArc to draw a single arc or XDrawArcs to draw mul-
  8859. tiple arcs in the specified drawable.
  8860.  
  8861.  
  8862. The definition for XDrawArc is:
  8863.  
  8864. XDrawArc(display, d, gc, x, y, width, height, angle1, angle2)
  8865.       Display *display;
  8866.       Drawable d;
  8867.       GC gc;
  8868.       int x, y;
  8869.       unsigned int width, height;
  8870.       int angle1, angle2;
  8871.  
  8872.  
  8873. display   Specifies the connection to the X server.
  8874.  
  8875. d         Specifies the drawable.
  8876.  
  8877. gc        Specifies the graphics context.
  8878.  
  8879. x
  8880. y         Specify the x and y coordinates.  These are the
  8881.           coordinates of the arc and are relative to the
  8882.           origin of the drawable.  These coordinates also
  8883.           specify the upper left corner of the rectangle.
  8884.  
  8885. width
  8886. height    Specify the width and height.  These are the major
  8887.           and minor axes of the arc.
  8888.  
  8889. angle1    Specifies the start of the arc relative to the
  8890.           three-o-clock position from the center, in units
  8891.           of degrees * 64.
  8892.  
  8893.  
  8894.  
  8895.  
  8896.  
  8897.  
  8898.                      December 18, 1987
  8899.  
  8900.  
  8901.  
  8902.  
  8903.  
  8904.                           - 129 -
  8905.  
  8906.  
  8907. angle2    Specifies the path and extent of the arc relative
  8908.           to the start of the arc, in units of degrees * 64.
  8909.  
  8910.  
  8911. The definition for XDrawArcs is:
  8912.  
  8913. XDrawArcs(display, d, gc, arcs, narcs)
  8914.       Display *display;
  8915.       Drawable d;
  8916.       GC gc;
  8917.       XArc *arcs;
  8918.       int narcs;
  8919.  
  8920.  
  8921. display   Specifies the connection to the X server.
  8922.  
  8923. d         Specifies the drawable.
  8924.  
  8925. gc        Specifies the graphics context.
  8926.  
  8927. arcs      Specifies a pointer to an array of arcs.
  8928.  
  8929. narcs     Specifies the number of arcs in the array.
  8930.  
  8931. XDrawArc draws a single circular or elliptical arc, while
  8932. XDrawArcs draws multiple circular or elliptical arcs.  Each
  8933. arc is specified by a rectangle and two angles. The x and y
  8934. coordinates are relative to the origin of the drawable and
  8935. define the upper left corner of the rectangle. The center of
  8936. the circle or ellipse is the center of the rectangle, and
  8937. the major and minor axes are specified by the width and
  8938. height, respectively. The angles are signed integers in
  8939. degrees scaled by 64 with positive indicating counterclock-
  8940. wise motion and negative indicating clockwise motion. The
  8941. start of the arc is specified by angle1 relative to the
  8942. three-o-clock position from the center of the rectangle, and
  8943. the path and extent of the arc are specified by angle2 rela-
  8944. tive to the start of the arc.  If the magnitude of angle2 is
  8945. greater than 360 degrees, XDrawArc or XDrawArcs truncates it
  8946. to 360 degrees.
  8947.  
  8948. The x and y coordinates of the rectangle are relative to the
  8949. origin of the drawable.  For an arc specified as
  8950. [x,y,w,h,a1,a2], the origin of the major and minor axes is
  8951. at [x+(w/2),y+(h/2)], and the infinitely thin path describ-
  8952. ing the entire circle or ellipse intersects the horizontal
  8953. axis at [x,y+(h/2)] and [x+w,y+(h/2)] and intersects the
  8954. vertical axis at [x+(w/2),y] and [x+(w/2),y+h].  These coor-
  8955. dinates can be fractional. That is, they are not truncated
  8956. to discrete coordinates.  The path should be defined by the
  8957. ideal mathematical path. For a wide line with line-width lw,
  8958. the bounding outlines for filling are given by the infin-
  8959. itely thin paths describing the arcs:
  8960.  
  8961.  
  8962.  
  8963.  
  8964.                      December 18, 1987
  8965.  
  8966.  
  8967.  
  8968.  
  8969.  
  8970.                           - 130 -
  8971.  
  8972.  
  8973.  
  8974.         [x+dx/2,y+dy/2,w-dx,h-dy,a1,a2]
  8975.                 and
  8976.         [x-lw/2,y-lw/2,w+lw,h+lw,a1,a2]
  8977.                 where
  8978.         dx=min(lw,w)
  8979.         dy=min(lw,h)
  8980.  
  8981.  
  8982. For an arc specified as [x,y,w,h,a1,a2], the angles must be
  8983. specified in the effectively skewed coordinate system of the
  8984. ellipse (for a circle, the angles and coordinate systems are
  8985. identical).  The relationship between these angles and
  8986. angles expressed in the normal coordinate system of the
  8987. screen (as measured with a protractor) is as follows:
  8988.  
  8989.  
  8990.         skewed-angle = atan(tan(normal-angle) * w/h) + adjust
  8991.  
  8992. The skewed-angle and normal-angle are expressed in radians
  8993. (rather than in degrees scaled by 64) in the range [0,2*PI),
  8994. and where atan returns a value in the range [-PI/2,PI/2],
  8995. and where adjust is:
  8996.  
  8997.  
  8998.         0        for normal-angle in the range [0,PI/2)
  8999.         PI       for normal-angle in the range [PI/2,(3*PI)/2)
  9000.         2*PI     for normal-angle in the range [(3*PI)/2,2*PI)
  9001.  
  9002.  
  9003. In the case of XDrawArc, you simply specify a single arc.
  9004. For XDrawArcs, you specify an array of XArc structures, each
  9005. of which contains an arc's x and y coordinates, width and
  9006. height, start position, and path and extent.  XDrawArcs
  9007. draws the arcs in the order listed in the array. For any
  9008. given arc, no pixel is drawn more than once. If two arcs
  9009. join correctly and if the line_width is greater than zero
  9010. and the arcs intersect, no pixel is drawn more than once.
  9011. Otherwise, the intersecting pixels of intersecting arcs are
  9012. drawn multiple times.  Specifying an arc with one endpoint
  9013. and a clockwise extent draws the same pixels as specifying
  9014. the other endpoint and an equivalent counterclockwise
  9015. extent, except as it affects joins.
  9016.  
  9017. If the last point in one arc coincides with the first point
  9018. in the following arc, the two arcs will join correctly. If
  9019. the first point in the first arc coincides with the last
  9020. point in the last arc, the two arcs will join correctly.  By
  9021. specifying one axis to be zero, a horizontal or vertical
  9022. line can be drawn.  Angles are computed based solely on the
  9023. coordinate system and ignore the aspect ratio.
  9024.  
  9025.  
  9026.  
  9027.  
  9028.                      December 18, 1987
  9029.  
  9030.  
  9031.  
  9032.  
  9033.  
  9034.                           - 131 -
  9035.  
  9036.  
  9037. XDrawArc and XDrawArcs use these graphics context com-
  9038. ponents: function, plane_mask, line_width, line_style,
  9039. cap_style, join_style, fill_style, subwindow_mode,
  9040. clip_x_origin, clip_y_origin, and clip_mask.  Both functions
  9041. also use these graphics context mode-dependent components:
  9042. foreground, background, tile, stipple, ts_x_origin,
  9043. ts_y_origin, dash_offset, and dash_list.
  9044.  
  9045. The errors that can be generated by XDrawArc and XDrawArcs
  9046. are BadDrawable, BadGC, and BadMatch.
  9047.  
  9048. 6.4.  Filling Areas
  9049.  
  9050. Xlib provides functions with which you can fill:
  9051.  
  9052. o    A single rectangle or multiple rectangles
  9053.  
  9054. o    A single polygon
  9055.  
  9056. o    A single arc or multiple arcs
  9057.  
  9058. 6.4.1.  Filling Single and Multiple Rectangles
  9059.  
  9060. Use XFillRectangle to fill a single rectangular area or
  9061. XFillRectangles to fill multiple rectangular areas in the
  9062. specified drawable.
  9063.  
  9064.  
  9065. The definition for XFillRectangle is:
  9066.  
  9067. XFillRectangle(display, d, gc, x, y, width, height)
  9068.       Display *display;
  9069.       Drawable d;
  9070.       GC gc;
  9071.       int x, y;
  9072.       unsigned int width, height;
  9073.  
  9074.  
  9075. display   Specifies the connection to the X server.
  9076.  
  9077. d         Specifies the drawable.
  9078.  
  9079. gc        Specifies the graphics context.
  9080.  
  9081. x
  9082. y         Specify the x and y coordinates.  These coordi-
  9083.           nates are relative to the origin of the drawable
  9084.           and specify the upper left corner of the rectan-
  9085.           gle.
  9086.  
  9087. width
  9088. height    Specify the width and height.  These are the
  9089.           dimensions of the rectangle to be filled.
  9090.  
  9091.  
  9092.  
  9093.  
  9094.                      December 18, 1987
  9095.  
  9096.  
  9097.  
  9098.  
  9099.  
  9100.                           - 132 -
  9101.  
  9102.  
  9103. The definition for XFillRectangles is:
  9104.  
  9105. XFillRectangles(display, d, gc, rectangles, nrectangles)
  9106.       Display *display;
  9107.       Drawable d;
  9108.       GC gc;
  9109.       XRectangle *rectangles;
  9110.       int nrectangles;
  9111.  
  9112.  
  9113. display   Specifies the connection to the X server.
  9114.  
  9115. d         Specifies the drawable.
  9116.  
  9117. gc        Specifies the graphics context.
  9118.  
  9119. rectanglesSpecifies a pointer to an array of rectangles.
  9120.  
  9121. nrectanglesSpecifies the number of rectangles in the array.
  9122.  
  9123. The XFillRectangle and XFillRectangles functions fill the
  9124. specified rectangle or rectangles as if a four-point
  9125. XFillPolygon were specified for each rectangle:
  9126.  
  9127.      [x,y] [x+width,y] [x+width,y+height] [x,y+height]
  9128.  
  9129. Each function uses the x and y coordinates, width and height
  9130. dimensions, and graphics context you specify.  Both func-
  9131. tions use these graphics context components: function,
  9132. plane_mask, fill_style, fill_rule, subwindow_mode,
  9133. clip_x_origin, clip_y_origin, and clip_mask.  The two func-
  9134. tions also use these graphics context mode_dependent com-
  9135. ponents: foreground, background, tile, stipple, ts_x_origin,
  9136. and ts_y_origin.
  9137.  
  9138. In the case of XFillRectangle, you simply specify a single
  9139. rectangle to be filled.  For XFillRectangles, you specify an
  9140. array of XRectangle structures, each of which contains a
  9141. rectangle's x and y coordinates and width and height.
  9142. XFillRectangles fills the rectangles in the order listed in
  9143. the array. The x and y coordinates of each rectangle are
  9144. relative to the drawable's origin and define the upper left
  9145. corner of the rectangle.  For any given rectangle, no pixel
  9146. is drawn more than once. If rectangles intersect, the inter-
  9147. secting pixels are drawn multiple times.
  9148.  
  9149. The errors that can be generated by XFillRectangle and
  9150. XFillRectangles are BadDrawable, BadGC, and BadMatch.
  9151.  
  9152. 6.4.2.  Filling a Single Polygon
  9153.  
  9154.  
  9155. Use XFillPolygon to fill a polygon area in the specified
  9156. drawable.  The definition for this function is:
  9157.  
  9158.  
  9159.  
  9160.                      December 18, 1987
  9161.  
  9162.  
  9163.  
  9164.  
  9165.  
  9166.                           - 133 -
  9167.  
  9168.  
  9169. XFillPolygon(display, d, gc, points, npoints, shape, mode)
  9170.       Display *display;
  9171.       Drawable d;
  9172.       GC gc;
  9173.       XPoint *points;
  9174.       int npoints;
  9175.       int shape;
  9176.       int mode;
  9177.  
  9178.  
  9179. display   Specifies the connection to the X server.
  9180.  
  9181. d         Specifies the drawable.
  9182.  
  9183. gc        Specifies the graphics context.
  9184.  
  9185. points    Specifies a pointer to an array of points.
  9186.  
  9187. npoints   Specifies the number of points in the array.
  9188.  
  9189. shape     Specifies an argument that helps the server to
  9190.           improve performance.  You can pass one of these
  9191.           constants:  Complex, Convex, or Nonconvex.
  9192.  
  9193. mode      Specifies the coordinate mode. CoordModeOrigin
  9194.           treats a coordinates as related to the origin,
  9195.           while CoordModePrevious treates all coordinates
  9196.           after the first as relative to the previous point.
  9197.  
  9198. The XFillPolygon function uses these graphics context com-
  9199. ponents when filling the polygon area: function, plane_mask,
  9200. fill_style, fill_rule, subwindow_mode, clip_x_origin,
  9201. clip_y_origin, and clip_mask.  This function also uses these
  9202. graphics context mode_dependent components: foreground,
  9203. tile, stipple, ts_x_origin, and ts_y_origin.  XFillPolygon
  9204. fills the region closed by the specified path.  The path is
  9205. closed automatically if the last point in the list does not
  9206. coincide with the first point.  No pixel of the region is
  9207. drawn more than once.
  9208.  
  9209. XFillPolygon requires a mode argument to determine whether
  9210. the points are relative to the drawable's origin or to the
  9211. previous point:
  9212.  
  9213. o    If mode is CoordModeOrigin, all points after the first
  9214.      are relative to the drawable's origin.  (The first
  9215.      point is always relative to the drawable's origin.)
  9216.  
  9217. o    If mode is CoordModePrevious, all points after the
  9218.      first are relative to the previous point.
  9219.  
  9220. XFillPolygon also requires a shape argument:
  9221.  
  9222.  
  9223.  
  9224.  
  9225.  
  9226.                      December 18, 1987
  9227.  
  9228.  
  9229.  
  9230.  
  9231.  
  9232.                           - 134 -
  9233.  
  9234.  
  9235. o    If shape is Complex, the path may self-intersect.
  9236.  
  9237. o    If shape is Nonconvex, the path does not self-
  9238.      intersect, but the shape is not wholly convex. If known
  9239.      by the client, specifying Nonconvex instead of Complex
  9240.      may improve performance. If you specify Nonconvex for a
  9241.      self-intersecting path, the graphics results are unde-
  9242.      fined.
  9243.  
  9244. o    If shape is Convex, the path is wholly convex. If known
  9245.      by the client, specifying Convex can improve perfor-
  9246.      mance. If you specify Convex for a path that is not
  9247.      convex, the graphics results are undefined.
  9248.  
  9249. The fill_rule member of the GC controls the filling behavior
  9250. of self-intersecting polygons.
  9251.  
  9252. The errors that can be generated by XFillPolygon are Bad-
  9253. Drawable, BadGC, BadMatch, and BadValue.
  9254.  
  9255. 6.4.3.  Filling Single and Multiple Arcs
  9256.  
  9257. Use XFillArc to fill a single arc or XFillArcs to fill mul-
  9258. tiple arcs in the specified drawable.  The definition for
  9259. XFillArc is:
  9260.  
  9261. XFillArc(display, d, gc,  x, y, width, height, angle1, angle2)
  9262.       Display *display;
  9263.       Drawable d;
  9264.       GC gc;
  9265.       int x, y;
  9266.       unsigned int width, height;
  9267.       int angle1, angle2;
  9268.  
  9269.  
  9270. display   Specifies the connection to the X server.
  9271.  
  9272. d         Specifies the drawable.
  9273.  
  9274. gc        Specifies the graphics context.
  9275.  
  9276. x
  9277. y         Specify the x and y coordinates.  These coordi-
  9278.           nates are relative to the origin of the drawable
  9279.           and specify the upper left corner of the rectan-
  9280.           gle.
  9281.  
  9282. width
  9283. height    Specify the width and height.  These are the major
  9284.           and minor axes of the arc.
  9285.  
  9286. angle1    Specifies the start of the arc relative to the
  9287.           three-o-clock position from the center, in units
  9288.           of degrees * 64.
  9289.  
  9290.  
  9291.  
  9292.                      December 18, 1987
  9293.  
  9294.  
  9295.  
  9296.  
  9297.  
  9298.                           - 135 -
  9299.  
  9300.  
  9301. angle2    Specifies the path and extent of the arc relative
  9302.           to the start of the arc, in units of degrees * 64.
  9303.  
  9304.  
  9305. The definition for XFillArcs is:
  9306.  
  9307. XFillArcs(display, d, gc, arcs, narcs)
  9308.       Display *display;
  9309.       Drawable d;
  9310.       GC gc;
  9311.       XArc *arcs;
  9312.       int narcs;
  9313.  
  9314.  
  9315. display   Specifies the connection to the X server.
  9316.  
  9317. d         Specifies the drawable.
  9318.  
  9319. gc        Specifies the graphics context.
  9320.  
  9321. arcs      Specifies a pointer to an array of arcs.
  9322.  
  9323. narcs     Specifies the number of arcs in the array.
  9324.  
  9325. For each arc, XFillArc or XFillArcs fills the region closed
  9326. by the infinitely thin path described by the specified arc
  9327. and, depending on the arc_mode specified in the graphics
  9328. context one or two line segments. For ArcChord, the single
  9329. line segment joining the endpoints of the arc is used. For
  9330. ArcPieSlice, the two line segments joining the endpoints of
  9331. the arc with the center point are used.
  9332.  
  9333. XFillArc and XFillArcs use these graphics context components
  9334. when filling the arc or arcs: function, plane_mask,
  9335. fill_style, arc_mode, subwindow_mode, clip_x_origin,
  9336. clip_y_origin, and clip_mask.  The two functions also use
  9337. these graphics context mode-dependent components: fore-
  9338. ground, background, tile, stipple, ts_x_origin, and
  9339. ts_y_origin.
  9340.  
  9341. In the case of XFillArc, you simply specify a single arc to
  9342. be filled.  For XFillArcs, you specify an array of XArc
  9343. structures, each of which contains an arc's x and y coordi-
  9344. nates, width and height, start position, and path and
  9345. extent.  XFillArcs fills the arcs in the order listed in the
  9346. array. For any given arc, no pixel is drawn more than once.
  9347. If regions intersect, the intersecting pixels are drawn mul-
  9348. tiple times.
  9349.  
  9350. The errors that can be generated by XFillArc and XFillArcs
  9351. are BadDrawable, BadGC, and BadMatch.
  9352.  
  9353.  
  9354.  
  9355.  
  9356.  
  9357.  
  9358.                      December 18, 1987
  9359.  
  9360.  
  9361.  
  9362.  
  9363.  
  9364.                           - 136 -
  9365.  
  9366.  
  9367. 6.5.  Manipulating Fonts
  9368.  
  9369. Xlib provides functions with which you can manipulate fonts.
  9370. The following sections discuss how to:
  9371.  
  9372. o    Load and free fonts
  9373.  
  9374. o    Obtain and free font names
  9375.  
  9376. o    Set and return the font search path
  9377.  
  9378. o    Compute character string sizes
  9379.  
  9380. o    Return logical extents
  9381.  
  9382. o    Query character string sizes Fonts and Information
  9383.      about Fonts
  9384.  
  9385. The X server loads fonts whenever a program requests a new
  9386. font.  Fonts are unloaded when the last font is no longer
  9387. referenced.  There is never more than one copy of a font
  9388. stored in the server at one time.  Fonts are global across
  9389. all screens in a server.  There are several levels one can
  9390. deal with fonts.  Most applications will simply use XLoad-
  9391. QueryFont to load a font and query the font metrics.
  9392.  
  9393. Characters in fonts are regarded as masks.  Except for image
  9394. text requests, the only pixels modified are those in which
  9395. bits are on in the character.  This means that it makes
  9396. sense to draw text using stipples or tiles (for example,
  9397. many menus gray-out unusable entries).
  9398.  
  9399. 6.5.1.  Loading and Freeing Fonts
  9400.  
  9401. Xlib provides functions with which you can load fonts, get
  9402. font information, unload fonts, and free font information.
  9403. A few font functions use a GContext in order to specify the
  9404. Graphics context for a font query.
  9405.  
  9406.  
  9407. Use XLoadFont to load the specified font.  The definition
  9408. for this function is:
  9409.  
  9410. Font XLoadFont(display, name)
  9411.       Display *display;
  9412.       char *name;
  9413.  
  9414.  
  9415. display   Specifies the connection to the X server.
  9416.  
  9417. name      Specifies the name of the font.  This name is a
  9418.           null terminated string.  You should use the ISO
  9419.           Latin-1 encoding, and upper/lower case does not
  9420.           matter.
  9421.  
  9422.  
  9423.  
  9424.                      December 18, 1987
  9425.  
  9426.  
  9427.  
  9428.  
  9429.  
  9430.                           - 137 -
  9431.  
  9432.  
  9433. The XLoadFont function loads the specified font and returns
  9434. its associated font ID.  If the function was unsuccessful at
  9435. loading the specified font, it generates a BadName error.
  9436. When the font is no longer needed, the client should call
  9437. XUnloadFont.  Fonts are not associated with a particular
  9438. screen and can be stored as a component of any graphics con-
  9439. text.
  9440.  
  9441. The errors that can be generated by XLoadFont are BadAlloc
  9442. and BadName.
  9443.  
  9444.  
  9445.  
  9446. Use XGContextFromGC to obtain the GContext for the specified
  9447. GC.  The definition for this function is:
  9448.  
  9449. GContext XGContextFromGC(gc)
  9450.       GC gc;
  9451.  
  9452.  
  9453. gc        Specifies the graphics context that you want the
  9454.           resource for.
  9455.  
  9456.  
  9457. Use XQueryFont to return information about a loaded font.
  9458. The definition for this function is:
  9459.  
  9460. XFontStruct *XQueryFont(display, font_ID)
  9461.       Display *display;
  9462.       XID font_ID;
  9463.  
  9464.  
  9465. display   Specifies the connection to the X server.
  9466.  
  9467. font_ID   Specifies the ID of the font or the graphics con-
  9468.           text whose current font you want font information
  9469.           about.
  9470.  
  9471. The XQueryFont function returns a pointer to the XFontStruct
  9472. structure, which contains information associated with the
  9473. font.  You can either query fonts or the fonts stored in the
  9474. GC.  Use XFreeFontInfo to free this data.  In this case, the
  9475. font ID stored in the XFontstruct will be the ID of the GC,
  9476. and you need to be careful when using this ID in other func-
  9477. tions.  For example, the ID of the GC is not valid as a font
  9478. ID in a call to a Set or Get font function.
  9479.  
  9480.  
  9481. Use XListFontsWithInfo to obtain the names and information
  9482. about loaded fonts.  The definition for this function is:
  9483.  
  9484.  
  9485.  
  9486.  
  9487.  
  9488.  
  9489.  
  9490.                      December 18, 1987
  9491.  
  9492.  
  9493.  
  9494.  
  9495.  
  9496.                           - 138 -
  9497.  
  9498.  
  9499. char **XListFontsWithInfo(display, pattern, maxnames, count_return, info_return)
  9500.       Display *display;
  9501.       char *pattern;
  9502.       int maxnames;
  9503.       int *count_return;
  9504.       XFontStruct **info_return;
  9505.  
  9506.  
  9507. display   Specifies the connection to the X server.
  9508.  
  9509. pattern   Specifies the null-terminated string associated
  9510.           with the font names that you want returned.  You
  9511.           can specify any string, an asterisk (*), or a
  9512.           question mark (?). The asterisk indicates a wild-
  9513.           card on any number of characters, and the question
  9514.           mark indicates a wildcard on a single character.
  9515.  
  9516. maxnames  Specifies the maximum number of names that are to
  9517.           be in the returned list.
  9518.  
  9519. count_returnReturns the actual number of matched font names.
  9520.  
  9521. info_returnReturns a pointer to the font information.
  9522.  
  9523. The XListFontsWithInfo function returns a list of names of
  9524. fonts that match the specified pattern and their associated
  9525. font information.  The list of names is limited to size
  9526. specified by the maxnames argument.  The information
  9527. returned for each font is identical to what XLoadQueryFont
  9528. would return, except that the per-character metrics are not
  9529. returned.  To free the allocated name array, the client
  9530. should call XFreeFontNames.  To free the the font informa-
  9531. tion array, the client should call XFreeFontInfo.
  9532.  
  9533.  
  9534. Use XFreeFontInfo to free the the font information array.
  9535. The definition for this function is:
  9536.  
  9537. XFreeFontInfo(names, free_info, actual_count)
  9538.       char **names;
  9539.       XFontStruct *free_info;
  9540.       int actual_count;
  9541.  
  9542.  
  9543. names     Specifies a pointer to the list of font names that
  9544.           were returned by XListFontsWithInfo.
  9545.  
  9546. free_info Specifies a pointer to the font information that
  9547.           was returned by XlistFontWithInfo.
  9548.  
  9549. actual_countSpecifies the actual number of matched font
  9550.           names that were returned by XlistFontsWithInfo.
  9551.  
  9552.  
  9553.  
  9554.  
  9555.  
  9556.                      December 18, 1987
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562.                           - 139 -
  9563.  
  9564.  
  9565. Use XLoadQueryFont to perform a XLoadFont and XQueryFont in
  9566. a single operation.  The definition for this function is:
  9567.  
  9568. XFontStruct *XLoadQueryFont(display, name)
  9569.       Display *display;
  9570.       char *name;
  9571.  
  9572.  
  9573. display   Specifies the connection to the X server.
  9574.  
  9575. name      Specifies the name of the font.  This name is a
  9576.           null terminated string.
  9577.  
  9578. The XLoadQueryFont function provides the most common way for
  9579. accessing a font.  That is, XLoadQueryFont both opens
  9580. (loads) the specified font and returns a pointer to the
  9581. appropriate XFontStruct structure.  If the font does not
  9582. exist, XLoadQueryFont returns NULL.
  9583.  
  9584. The XFontStruct structure contains all of the information
  9585. for the font and consists of the font specific information
  9586. as well as a pointer to an array of XCharStruct structures
  9587. for the characters contained in the font.  The information
  9588. in the XFontStruct, XFontProp, and XCharStruct structures
  9589. is:
  9590.  
  9591. typedef struct {
  9592.      short lbearing;          /* origin to left edge of raster */
  9593.      short rbearing;          /* origin to right edge of raster */
  9594.      short width;             /* advance to next char's origin */
  9595.      short ascent;            /* baseline to top edge of raster */
  9596.      short descent;           /* baseline to bottom edge of raster */
  9597.      unsigned short attributes;/* per char flags (not predefined) */
  9598. } XCharStruct;
  9599.  
  9600. typedef struct {
  9601.      Atom name;
  9602.      unsigned long card32;
  9603. } XFontProp;
  9604.  
  9605.  
  9606. typedef struct {              /* normal 16 bit characters are two bytes */
  9607.     unsigned char byte1;
  9608.     unsigned char byte2;
  9609. } XChar2b;
  9610.  
  9611.  
  9612.  
  9613.  
  9614.  
  9615.  
  9616.  
  9617.  
  9618.  
  9619.  
  9620.  
  9621.  
  9622.                      December 18, 1987
  9623.  
  9624.  
  9625.  
  9626.  
  9627.  
  9628.                           - 140 -
  9629.  
  9630.  
  9631. typedef struct {
  9632.      XExtData    *ext_data;   /* hook for extension to hang data */
  9633.      Font        fid;         /* Font id for this font */
  9634.      unsigned    direction;   /* hint about the direction font is painted */
  9635.      unsigned    min_char_or_byte2;/* first character */
  9636.      unsigned    max_char_or_byte2;/* last character */
  9637.      unsigned    min_byte1;   /* first row that exists */
  9638.      unsigned    max_byte1;   /* last row that exists */
  9639.      Bool        all_chars_exist;/* flag if all characters
  9640.                               have nonzero size*/
  9641.      unsigned    default_char;/* char to print for undefined character */
  9642.      int         n_properties;/* how many properties there are */
  9643.      XFontProp   *properties; /* pointer to array of
  9644.                               additional properties*/
  9645.      XCharStruct min_bounds;  /* minimum bounds over all existing char*/
  9646.      XCharStruct max_bounds;  /* maximum bounds over all existing char*/
  9647.      XCharStruct *per_char;   /* first_char to last_char information */
  9648.      int         ascent;      /* logical extent above baseline for spacing */
  9649.      int         descent;     /* logical decent below baseline for spacing */
  9650. } XFontStruct;
  9651.  
  9652.  
  9653. X supports both single byte/character and two
  9654. bytes/character text operations.  Note that either form can
  9655. be used with a font, but a single byte/character text
  9656. requests can only specify a single byte (that is, the first
  9657. row of a two byte font).  You should view two byte fonts as
  9658. a two dimensional matrix of defined characters: byte1 speci-
  9659. fies the range of defined rows and byte2 defines the range
  9660. of defined columns of the font.  Single byte/character fonts
  9661. have no rows defined, and the byte2 range specified in the
  9662. structure defines a range of characters.
  9663.  
  9664. The bounding box of a character is defined by the XChar-
  9665. Struct of that character (see below).  However, characters
  9666. may be absent from a font.  In this case, the default font
  9667. is used.  Some fonts may have characters all the same size.
  9668. In this case, only the information in the XFontStruct char-
  9669. acters are used.
  9670.  
  9671. The members of the XFontStruct structure are:
  9672.  
  9673. o    The direction member can be either FontLeftToRight or
  9674.      FontRightToLeft.  Essentially, it is just a hint as to
  9675.      whether most XCharStruct elements have a positive (
  9676.      FontLeftToRight) or a negative  ( FontRightToLeft)
  9677.      character-width metric.  The core protocol defines no
  9678.      support for vertical text.
  9679.  
  9680. o    If the min_byte1 and max_byte1 members are both zero,
  9681.      min_char_or_byte2 specifies the linear character index
  9682.      corresponding to the first element of the per_char
  9683.      array, and max_char_or_byte2 specifies the linear char-
  9684.      acter index of the last element.
  9685.  
  9686.  
  9687.  
  9688.                      December 18, 1987
  9689.  
  9690.  
  9691.  
  9692.  
  9693.  
  9694.                           - 141 -
  9695.  
  9696.  
  9697.      If either min_byte1 or max_byte1 are nonzero, both
  9698.      min_char_or_byte2 and max_char_or_byte2 will be less
  9699.      than 256, and the two-byte character index values
  9700.      corresponding to the per_char array element N (counting
  9701.      from 0) are:
  9702.  
  9703.           byte1 = N/D + min_byte1
  9704.           byte2 = N\D + min_char_or_byte2
  9705.  
  9706.      where:
  9707.  
  9708.              D = max_char_or_byte2 - min_char_or_byte2 + 1
  9709.              / = integer division
  9710.              \ = integer modulus
  9711.  
  9712. o    If the per_char pointer is NULL, all glyphs between the
  9713.      first and last character indexes inclusive have the
  9714.      same information, as given by both min_bounds and
  9715.      max_bounds.
  9716.  
  9717. o    If all_chars_exist is True, all characters in the
  9718.      per_char array have nonzero bounding boxes.
  9719.  
  9720. o    The default_char member specifies the character that
  9721.      will be used when an undefined or nonexistent character
  9722.      is used. The default_char is a 16 bit character (not a
  9723.      two byte character).  For a font using two byte matrix
  9724.      format, the default_char has byte1 in the most signifi-
  9725.      cant byte, and byte2 in the least significant byte.  If
  9726.      the default_char itself specifies an undefined or
  9727.      nonexistent character, no printing is performed for an
  9728.      undefined or nonexistent character.
  9729.  
  9730. o    The min_bounds and max_bounds members contain the most
  9731.      extreme values of each individual XCharStruct component
  9732.      over all elements of this array (ignores nonexistent
  9733.      characters).  The bounding box of the font (the smal-
  9734.      lest rectangle enclosing the shape obtained by superim-
  9735.      posing all of the characters at the same origin [x,y])
  9736.      has its upper left coordinate at:
  9737.  
  9738.           [x + min_bounds.lbearing, y - max_bounds.ascent]
  9739.  
  9740.      Its width is:
  9741.  
  9742.           max_bounds.rbearing - min_bounds.lbearing
  9743.  
  9744.      Its height is:
  9745.           max_bounds.ascent + max_bounds.descent
  9746.  
  9747.      The x and y are the lower left corner of the box that
  9748.      is relative to the origin.
  9749.  
  9750.  
  9751.  
  9752.  
  9753.  
  9754.                      December 18, 1987
  9755.  
  9756.  
  9757.  
  9758.  
  9759.  
  9760.                           - 142 -
  9761.  
  9762.  
  9763. o    The ascent member is the logical extent of the font
  9764.      above the baseline that is used for determining line
  9765.      spacing.  Specific characters may extend beyond this.
  9766.  
  9767. o    The descent member is the logical extent of the font at
  9768.      or below the baseline that is used for determining line
  9769.      spacing.  Specific characters may extend beyond this.
  9770.      If the baseline is at Y-coordinate y, the logical
  9771.      extent of the font is inclusive between the Y-
  9772.      coordinate values (y-font.ascent) and (y + font.descent
  9773.      - 1).
  9774.  
  9775. A font is not guaranteed to have any properties.  The
  9776. interpretation of the property value (for example, int32,
  9777. card32) must be derived from a priori knowledge of the pro-
  9778. perty. When possible, fonts should have at least the proper-
  9779. ties listed in the following table.  With atom names,
  9780. upper/lower case matters.  The following builtin property
  9781. atoms can be found in <X11/Xatom.h>.
  9782.  
  9783.  
  9784. ____________________________________________________________________
  9785. Property Name         Type       Description
  9786. ____________________________________________________________________
  9787. MIN_SPACE
  9788.                       unsigned
  9789.                                  The minimum interword spacing (in
  9790.                                  pixels).
  9791.  
  9792.  
  9793. NORM_SPACE
  9794.                       unsigned
  9795.                                  The normal interword spacing (in
  9796.                                  pixels).
  9797.  
  9798.  
  9799. MAX_SPACE
  9800.                       unsigned
  9801.                                  The maximum interword spacing (in
  9802.                                  pixels).
  9803.  
  9804.  
  9805. END_SPACE
  9806.                       unsigned
  9807.                                  The additional spacing (in pixels)
  9808.                                  at the end of sentences.
  9809.  
  9810.  
  9811. SUPERSCRIPT_X
  9812.                       int
  9813.                                  Offset from the character origin
  9814.                                  where superscripts should begin (in
  9815.                                  pixels).  If the origin is at
  9816.                                  [x,y], then superscripts should
  9817.                                  begin at
  9818.                                  [x + SUPERSCRIPT_X, y -
  9819.                                  SUPERSCRIPT_Y].
  9820.  
  9821.  
  9822.  
  9823.  
  9824.  
  9825.  
  9826.  
  9827. SUPERSCRIPT_Y
  9828.                       int
  9829.                                  Offset from the character origin
  9830.                                  where superscripts should begin (in
  9831.                                  pixels).  If the origin is at
  9832.                                  [x,y], then superscripts should
  9833.                                  begin at
  9834.                                  [x + SUPERSCRIPT_X, y -
  9835.                                  SUPERSCRIPT_Y].
  9836.  
  9837.  
  9838.  
  9839.  
  9840.  
  9841.  
  9842.  
  9843. SUBSCRIPT_X
  9844.                       int
  9845.                                  Offset from the character origin
  9846.                                  where subscripts should begin (in
  9847.                                  pixels).  If the origin is at
  9848.                                  [x,y], then subscripts should begin
  9849.                                  at
  9850.  
  9851.  
  9852.                      December 18, 1987
  9853.  
  9854.  
  9855.  
  9856.  
  9857.  
  9858.                           - 143 -
  9859.  
  9860.  
  9861. ____________________________________________________________________
  9862. Property Name         Type       Description
  9863. ____________________________________________________________________
  9864.                                  [x + SUPERSCRIPT_X, y +
  9865.                                  SUPERSCRIPT_Y].
  9866.  
  9867.  
  9868.  
  9869.  
  9870.  
  9871.  
  9872.  
  9873.  
  9874.  
  9875.  
  9876.  
  9877.  
  9878.  
  9879.  
  9880.  
  9881.  
  9882.  
  9883.  
  9884.  
  9885.  
  9886.  
  9887.  
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.  
  9894.  
  9895.  
  9896.  
  9897.  
  9898.  
  9899.  
  9900.  
  9901.  
  9902.  
  9903.  
  9904.  
  9905.  
  9906.  
  9907.  
  9908.  
  9909.  
  9910.  
  9911.  
  9912.  
  9913.  
  9914.  
  9915.  
  9916.  
  9917.                      December 18, 1987
  9918.  
  9919.  
  9920.  
  9921.  
  9922.  
  9923.                           - 144 -
  9924.  
  9925.  
  9926. ____________________________________________________________________
  9927. Property Name         Type       Description
  9928. ____________________________________________________________________
  9929.  
  9930.  
  9931.  
  9932.  
  9933.  
  9934.  
  9935.  
  9936.  
  9937.  
  9938.  
  9939.  
  9940.  
  9941.  
  9942.  
  9943.  
  9944.  
  9945.  
  9946.  
  9947.  
  9948.  
  9949.  
  9950.  
  9951.  
  9952.  
  9953.  
  9954.  
  9955.  
  9956.  
  9957.  
  9958.  
  9959.  
  9960.  
  9961.  
  9962.  
  9963.  
  9964.  
  9965.  
  9966.  
  9967.  
  9968.  
  9969.  
  9970.  
  9971.  
  9972.  
  9973.  
  9974.  
  9975.  
  9976.  
  9977.  
  9978.  
  9979.  
  9980.  
  9981.  
  9982.                      December 18, 1987
  9983.  
  9984.  
  9985.  
  9986.  
  9987.  
  9988.                           - 145 -
  9989.  
  9990.  
  9991. ____________________________________________________________________
  9992. Property Name         Type       Description
  9993. ____________________________________________________________________
  9994. SUBSCRIPT_Y
  9995.                       int
  9996.                                  Offset from the character origin
  9997.                                  where subscripts should begin (in
  9998.                                  pixels).  If the origin is at
  9999.                                  [x,y], then subscripts should begin
  10000.                                  at
  10001.                                  [x + SUPERSCRIPT_X, y +
  10002.                                  SUPERSCRIPT_Y].
  10003.  
  10004.  
  10005.  
  10006.  
  10007.  
  10008.  
  10009.  
  10010. UNDERLINE_POSITION
  10011.                       int
  10012.                                  Y offset from the baseline to the
  10013.                                  top of an underline (in pixels).
  10014.                                  If the baseline is Y-coordinate y,
  10015.                                  then the top of the underline is at
  10016.                                  (y + UNDERLINE_POSITION).
  10017.  
  10018.  
  10019.  
  10020.  
  10021.  
  10022. UNDERLINE_THICKNESS
  10023.                       unsigned
  10024.                                  Thickness of the underline (in pix-
  10025.                                  els)
  10026.  
  10027.  
  10028. STRIKEOUT_ASCENT
  10029.                       int
  10030.                                  Vertical extents for boxing or
  10031.                                  voiding characters (in pixels).  If
  10032.                                  the baseline is at Y-coordinate y,
  10033.                                  then the top of the strikeout box
  10034.                                  is at (y - STRIKEOUT_ASCENT), and
  10035.                                  the height of the box is
  10036.                                  (STRIKEOUT_ASCENT +
  10037.                                  STRIKEOUT_DESCENT).
  10038.  
  10039.  
  10040.  
  10041.  
  10042.  
  10043.  
  10044.  
  10045.  
  10046. STRIKEOUT_DESCENT
  10047.                       int
  10048.                                  Vertical extents for boxing or
  10049.                                  voiding characters (in pixels).  If
  10050.                                  the baseline is at Y-coordinate y,
  10051.                                  then the top of the strikeout box
  10052.                                  is at (y - STRIKEOUT_ASCENT), and
  10053.                                  the height of the box is
  10054.                                  (STRIKEOUT_ASCENT +
  10055.                                  STRIKEOUT_DESCENT).
  10056.  
  10057.  
  10058.  
  10059.  
  10060.  
  10061.  
  10062.  
  10063.  
  10064. ITALIC_ANGLE
  10065.                       int
  10066.                                  The angle of the dominant staffs of
  10067.                                  characters in the font, in degrees
  10068.                                  scaled by 64, relative to the
  10069.                                  three-o-clock position from the
  10070.                                  character origin, with positive
  10071.                                  indicating counterclockwise motion
  10072.                                  (as in the XDrawArc functions).
  10073.  
  10074.  
  10075.  
  10076.  
  10077.  
  10078.  
  10079.  
  10080. X_HEIGHT
  10081.                       int
  10082.                                  ``1 ex'' as in TeX, but expressed
  10083.                                  in units of pixels.  Often the
  10084.                                  height of lowercase x.
  10085.  
  10086.  
  10087.  
  10088. QUAD_WIDTH
  10089.                       int
  10090.                                  ``1 em'' as in TeX, but expressed
  10091.                                  in units of pixels.  Often the
  10092.                                  width of the digits 0-9.
  10093.  
  10094.  
  10095.  
  10096.  
  10097.  
  10098.  
  10099.  
  10100.  
  10101.  
  10102.                      December 18, 1987
  10103.  
  10104.  
  10105.  
  10106.  
  10107.  
  10108.                           - 146 -
  10109.  
  10110.  
  10111. ____________________________________________________________________
  10112. Property Name         Type       Description
  10113. ____________________________________________________________________
  10114. WEIGHT
  10115.                       unsigned
  10116.                                  The weight or boldness of the font,
  10117.                                  expressed as a value between 0 and
  10118.                                  1000.
  10119.  
  10120.  
  10121.  
  10122. POINT_SIZE
  10123.                       unsigned
  10124.                                  The point size of this font at the
  10125.                                  ideal resolution, expressed in
  10126.                                  1/10ths of points. There are 72.27
  10127.                                  points to the inch.
  10128.  
  10129.  
  10130.  
  10131.  
  10132. RESOLUTION
  10133.                       unsigned
  10134.                                  The number of pixels per point,
  10135.                                  expressed in 1/100ths, at which
  10136.                                  this font was created.
  10137.  
  10138.  
  10139.  
  10140. CAP_HEIGHT
  10141.                       int
  10142.                                  Y offset from the baseline to the
  10143.                                  top of the capital letters, ignor-
  10144.                                  ing accents, in pixels.  If the
  10145.                                  baseline is at Y-coordinate y, then
  10146.                                  the top of the capitals is at
  10147.                                  (y - CAP_HEIGHT).
  10148.  
  10149.  
  10150.  
  10151.  
  10152.  
  10153.  
  10154. ____________________________________________________________________
  10155.  
  10156.  
  10157. For a character origin at [x,y], the bounding box of a char-
  10158. acter (the smallest rectangle, described in terms of XChar-
  10159. Struct components, enclosing the character's shape) is a
  10160. rectangle with its upper left corner at:
  10161.  
  10162.      [x + lbearing, y - ascent]
  10163.  
  10164. Its width is:
  10165.  
  10166.      rbearing - lbearing
  10167.  
  10168. Its height is:
  10169.  
  10170.      ascent + descent
  10171.  
  10172. The origin for the next character is defined to be:
  10173.  
  10174.      [x + character-width, y]
  10175.  
  10176. Note that the baseline is logically viewed as being just
  10177. below nondescending characters. When descent is zero, only
  10178. pixels with Y-coordinates less than y are drawn.  And, the
  10179. origin is logically viewed as being coincident with the left
  10180. edge of a nonkerned character. When lbearing is zero (0), no
  10181. pixels with X-coordinate less than x are drawn).  Any of
  10182. these values could be negative.
  10183.  
  10184. The interpretation of the attributes member in the XChar-
  10185. Struct structure is not defined by the core X protocol.  A
  10186. nonexistent character is represented with all members of
  10187.  
  10188.  
  10189.  
  10190.                      December 18, 1987
  10191.  
  10192.  
  10193.  
  10194.  
  10195.  
  10196.                           - 147 -
  10197.  
  10198.  
  10199. XCharStruct set to zero (0).
  10200.  
  10201. The error that can be generated by XLoadQueryFont is BadAl-
  10202. loc.
  10203.  
  10204.  
  10205. Use XFreeFont to unload the font and free the storage used
  10206. by the font structure that was allocated by XQueryFont or
  10207. XLoadQueryFont.  The definition for this function is:
  10208.  
  10209. XFreeFont(display, font_struct)
  10210.       Display *display;
  10211.       XFontStruct *font_struct;
  10212.  
  10213.  
  10214. display   Specifies the connection to the X server.
  10215.  
  10216. font_structSpecifies the storage associated with the font.
  10217.  
  10218. The XFreeFont function deletes the association between the
  10219. font resource ID and the specified font.  The font itself
  10220. will be freed when no other resource references it.  The
  10221. data and the font should not be referenced again.
  10222.  
  10223. The error that can be generated by XFreeFont is BadFont.
  10224.  
  10225.  
  10226. Use XGetFontProperty to return the specified font property.
  10227. The definition for this function is:
  10228.  
  10229. Bool XGetFontProperty(font_struct, atom, value_return)
  10230.       XFontStruct *font_struct;
  10231.       Atom atom;
  10232.       unsigned long *value_return;
  10233.  
  10234.  
  10235. font_structSpecifies the storage associated with the font.
  10236.  
  10237. atom      Specifies the atom associated with the string name
  10238.           you want returned.
  10239.  
  10240.  
  10241. value_returnReturns the value of the font property.
  10242.  
  10243. Given the atom for that property, the XGetFontProperty func-
  10244. tion returns the value of the specified font property. The
  10245. function returns zero (0) if the atom was not defined or one
  10246. (1) if it was defined.  There are a set of predefined atoms
  10247. for font properties which can be found in <X11/Xatom.h>.
  10248. This set contains the standard properties associated with a
  10249. font.  While not guaranteed to be present, it it is very
  10250. likely that the predefined font properties will be present.
  10251.  
  10252.  
  10253.  
  10254.  
  10255.  
  10256.                      December 18, 1987
  10257.  
  10258.  
  10259.  
  10260.  
  10261.  
  10262.                           - 148 -
  10263.  
  10264.  
  10265. Use XUnloadFont to unload the specified font that was loaded
  10266. by XLoadFont.  The definition for this function is:
  10267.  
  10268. XUnloadFont(display, font)
  10269.       Display *display;
  10270.       Font font;
  10271.  
  10272.  
  10273. display   Specifies the connection to the X server.
  10274.  
  10275. font      Specifies the font ID.
  10276.  
  10277. The XUnloadFont function deletes the association between the
  10278. font resource ID and the specified font.  The font itself
  10279. will be freed when no other resource references it. The font
  10280. may be unloaded on the X server if this is the last refer-
  10281. ence to the font.  In any case, the font should never again
  10282. be referenced because the resource ID is destroyed.
  10283.  
  10284. The error that can be generated by XUnloadFont is BadFont.
  10285.  
  10286. 6.5.2.  Obtaining and Freeing Font Names
  10287.  
  10288. Xlib provides functions with which you can obtain and free
  10289. font names.  Fonts have font names that usually are related
  10290. or obvious.  These functions let you obtain font names by
  10291. matching a wild card specification by querying a font type
  10292. for a list of available sizes, and so on.
  10293.  
  10294.  
  10295. Use XListFonts to return a list of the available font names.
  10296. The definition for this function is:
  10297.  
  10298. char **XListFonts(display, pattern, maxnames, actual_count_return)
  10299.       Display *display;
  10300.       char *pattern;
  10301.       int maxnames;
  10302.       int *actual_count_return;
  10303.  
  10304.  
  10305. display   Specifies the connection to the X server.
  10306.  
  10307. pattern   Specifies the null-terminated string associated
  10308.           with the font names that you want returned.  You
  10309.           can specify any string, an asterisk (*), or a
  10310.           question mark (?). The asterisk indicates a wild-
  10311.           card on any number of characters, and the question
  10312.           mark indicates a wildcard on a single character.
  10313.  
  10314. maxnames  Specifies the maximum number of names that are to
  10315.           be in the returned list.
  10316.  
  10317.  
  10318.  
  10319.  
  10320.  
  10321.  
  10322.                      December 18, 1987
  10323.  
  10324.  
  10325.  
  10326.  
  10327.  
  10328.                           - 149 -
  10329.  
  10330.  
  10331. actual_count_returnReturns the actual number of font names.
  10332.  
  10333. The XListFonts function returns an array of font names that
  10334. match the string you passed to the pattern argument.  The
  10335. string should be ISO Latin-1, and upper/lower case does not
  10336. matter.  Each string is terminated by NULL.  The maximum
  10337. number of names returned in the list depends on the value
  10338. you passed to the maxnames argument.  The function places
  10339. the actual number of font names returned in the
  10340. actual_count_return argument.  The client should call
  10341. XFreeFontNames when done with the result to free the memory.
  10342.  
  10343.  
  10344. Use XFreeFontNames to free a font name array.  The defini-
  10345. tion for this function is:
  10346.  
  10347. XFreeFontNames(list)
  10348.       char *list[];
  10349.  
  10350.  
  10351. list      Specifies the array of strings you want to free.
  10352.  
  10353. The XFreeFontNames function frees the array and strings
  10354. returned by XListFonts.
  10355.  
  10356. 6.5.3.  Setting and Retrieving the Font Search Path
  10357.  
  10358. Xlib provides functions with which you can set and retrieve
  10359. the font search path.
  10360.  
  10361.  
  10362. Use XSetFontPath to set the font search path.  The defini-
  10363. tion for this function is:
  10364.  
  10365. XSetFontPath(display, directories, ndirs)
  10366.       Display *display;
  10367.       char **directories;
  10368.       int ndirs;
  10369.  
  10370.  
  10371. display   Specifies the connection to the X server.
  10372.  
  10373. directoriesSpecifies the directory path used to look for a
  10374.           font.  Setting the path to the empty list restores
  10375.           the default path defined for the X server.
  10376.  
  10377. ndirs     Specifies the number of directories in the path.
  10378.  
  10379. The XSetFontPath function defines the directory search path
  10380. for font lookup.  There is only one search path per X
  10381. server, not one per client.  The interpretation of the
  10382. strings is operating system dependent, but they are intended
  10383. to specify directories to be searched in the order listed.
  10384. Also, the contents of these strings are operating system
  10385.  
  10386.  
  10387.  
  10388.                      December 18, 1987
  10389.  
  10390.  
  10391.  
  10392.  
  10393.  
  10394.                           - 150 -
  10395.  
  10396.  
  10397. specific and are not intended to be used by client applica-
  10398. tions.  Usually, the X server is free to cache font informa-
  10399. tion internally rather than having to read fonts from files.
  10400. As a side-effect of executing this function, the X server is
  10401. guaranteed to flush all cached information about fonts for
  10402. which there currently are no explicit resource IDs allo-
  10403. cated.  The meaning of an error from this request is system
  10404. specific.
  10405.  
  10406. The error that can be generated by XSetFontPath is BadValue.
  10407.  
  10408.  
  10409. Use XGetFontPath to get the current font search path.  The
  10410. definition for this function is:
  10411.  
  10412. char **XGetFontPath(display, npaths_return)
  10413.       Display *display;
  10414.       int *npaths_return;
  10415.  
  10416.  
  10417.  
  10418. display   Specifies the connection to the X server.
  10419.  
  10420. npaths_returnReturns the number of strings in the font path
  10421.           array.
  10422.  
  10423. The XGetFontPath function allocates and returns an array of
  10424. strings containing the search path.  The data in the font
  10425. path should be freed when no longer needed.
  10426.  
  10427.  
  10428. Use XFreeFontPath to free data returned by XGetFontPath.
  10429. The definition for this function is:
  10430.  
  10431. XFreeFontPath(list)
  10432.       char **list;
  10433.  
  10434.  
  10435.  
  10436. list      Specifies the array of strings you want to free.
  10437.  
  10438. The XFreeFontPath function, when presented the data from
  10439. XGetFontPath, frees the data used by the array.
  10440.  
  10441. 6.5.4.  Computing Character String Sizes
  10442.  
  10443. Xlib provides functions with which you can compute the
  10444. width, the logical extents, and server information about 8-
  10445. bit and 16-bit text strings.
  10446.  
  10447.  
  10448. Use XTextWidth to determine the width of an 8-bit character
  10449. string or XTextWidth16 to determine the width of a 16-bit
  10450. character.  Width is computed by adding the character widths
  10451.  
  10452.  
  10453.  
  10454.                      December 18, 1987
  10455.  
  10456.  
  10457.  
  10458.  
  10459.  
  10460.                           - 151 -
  10461.  
  10462.  
  10463. of all of the characters.  It does not matter if the font is
  10464. an 8-bit or 16-bit font.  These functions return the sum of
  10465. the character metrics, in pixels.  The definition for
  10466. XTextWidth is:
  10467.  
  10468. int XTextWidth(font_struct, string, count)
  10469.       XFontStruct *font_struct;
  10470.       char *string;
  10471.       int count;
  10472.  
  10473.  
  10474. font_structSpecifies the font used for the width computa-
  10475.           tion.
  10476.  
  10477. string    Specifies the character string.
  10478.  
  10479. count     Specifies the character count in the named string.
  10480.  
  10481.  
  10482. The definition for XTextWidth16 is:
  10483.  
  10484. int XTextWidth16(font_struct, string, count)
  10485.       XFontStruct *font_struct;
  10486.       XChar2b *string;
  10487.       int count;
  10488.  
  10489.  
  10490. font_structSpecifies the font used for the width computa-
  10491.           tion.
  10492.  
  10493. string    Specifies the character string.
  10494.  
  10495. count     Specifies the character count in the named string.
  10496.  
  10497. 6.5.5.  Returning Logical Extents
  10498.  
  10499. Use XTextExtents to determine the logical extents of the
  10500. specified 8-bit character string or XTextExtents16 to return
  10501. the logical extents of the specified 16-bit character
  10502. string.  The logical extents of a string is the width and
  10503. height of the bounding box occupied by the string in the
  10504. specified font.  The definition for XTextExtents is:
  10505.  
  10506. XTextExtents(font_struct, string, nchars, direction_return, ascent_return, descent_return,
  10507.                overall_return)
  10508.       XFontStruct *font_struct;
  10509.       char *string;
  10510.       int nchars;
  10511.       int *direction_return;
  10512.       int *ascent_return, *descent_return;
  10513.       XCharStruct *overall_return;
  10514.  
  10515.  
  10516.  
  10517.  
  10518.  
  10519.  
  10520.                      December 18, 1987
  10521.  
  10522.  
  10523.  
  10524.  
  10525.  
  10526.                           - 152 -
  10527.  
  10528.  
  10529. font_structSpecifies a pointer to the XFontStruct structure.
  10530.  
  10531. string    Specifies the character string.
  10532.  
  10533. nchars    Specifies the number of characters in the charac-
  10534.           ter string.
  10535.  
  10536. direction_returnReturns the value of the direction hint
  10537.           member:  FontLeftToRight or FontRightToLeft.
  10538.  
  10539. ascent_returnReturns the font ascent member.
  10540.  
  10541. descent_returnReturns the font descent member.
  10542.  
  10543. overall_returnReturns the overall size in the specified
  10544.           XCharStruct structure.
  10545.  
  10546.  
  10547. The definition for XTextExtents16 is:
  10548.  
  10549. XTextExtents16(font_struct, string, nchars, direction_return, ascent_return, descent_return,
  10550.                  overall_return)
  10551.       XFontStruct *font_struct;
  10552.       XChar2b *string;
  10553.       int nchars;
  10554.       int *direction_return;
  10555.       int *ascent_return, *descent_return;
  10556.       XCharStruct *overall_return;
  10557.  
  10558.  
  10559.  
  10560. font_structSpecifies a pointer to the XFontStruct structure.
  10561.  
  10562. string    Specifies the character string.
  10563.  
  10564. nchars    Specifies the number of characters in the charac-
  10565.           ter string.
  10566.  
  10567. direction_returnReturns the value of the direction hint
  10568.           member:  FontLeftToRight or FontRightToLeft.
  10569.  
  10570. ascent_returnReturns the font ascent member.
  10571.  
  10572. descent_returnReturns the font descent member.
  10573.  
  10574. overall_returnReturns the overall size in the specified
  10575.           XCharStruct structure.
  10576.  
  10577. The XTextExtent and XTextExtents16 functions perform the
  10578. size computation locally and, thereby, avoid the roundtrip
  10579. overhead of XQueryTextExtents and XQueryTextExtents16.  For
  10580. the elements returned from the ascent is the maximum of the
  10581. ascent metrics of all characters in the string.  The descent
  10582. is the maximum of the descent metrics.  The width is the sum
  10583.  
  10584.  
  10585.  
  10586.                      December 18, 1987
  10587.  
  10588.  
  10589.  
  10590.  
  10591.  
  10592.                           - 153 -
  10593.  
  10594.  
  10595. of the character-width metrics of all characters in the
  10596. string.  For each character in the string, let W be the sum
  10597. of the character-width metrics of all characters preceding
  10598. it in the string.  Let R be the right-side-bearing metric of
  10599. the character plus W.  The lbearing member is the minimum L
  10600. of all characters in the string.  The rbearing member is the
  10601. maximum R.
  10602.  
  10603. For fonts defined with linear indexing rather than two-byte
  10604. matrix indexing, the X server interprets each XChar2b as a
  10605. 16-bit number that has been transmitted with the most signi-
  10606. ficant byte first.  That is, byte1 of the XChar2b is taken
  10607. as the most significant byte.  If the font has no defined
  10608. default character, undefined characters in the string are
  10609. taken to have all zero metrics.
  10610.  
  10611. 6.5.6.  Querying Character String Sizes
  10612.  
  10613. Use XQueryTextExtents to query the server for the sizes of
  10614. an 8-bit character string or XQueryTextExtents16 to query
  10615. the server for the sizes of a 16-bit character string.  The
  10616. definition for XQueryTextExtents is:
  10617.  
  10618. XQueryTextExtents(display, font_ID, string, nchars,direction_return, ascent_return,
  10619.                     descent_return, overall_return)
  10620.       Display *display;
  10621.       XID font_ID;
  10622.       char *string;
  10623.       int nchars;
  10624.       int *direction_return;
  10625.       int *ascent_return, *descent_return;
  10626.       XCharStruct *overall_return;
  10627.  
  10628.  
  10629. display   Specifies the connection to the X server.
  10630.  
  10631. font_ID   Specifies either the font ID or the graphics con-
  10632.           text that contains the font.
  10633.  
  10634. string    Specifies the character string.
  10635.  
  10636. nchars    Specifies the number of characters in the charac-
  10637.           ter string.
  10638.  
  10639. direction_returnReturns the value of the direction hint
  10640.           member:  FontLeftToRight or FontRightToLeft.
  10641.  
  10642. ascent_returnReturns the font ascent member.
  10643.  
  10644. descent_returnReturns the font descent member.
  10645.  
  10646. overall_returnReturns the overall size in the specified
  10647.           XCharStruct structure.
  10648.  
  10649.  
  10650.  
  10651.  
  10652.                      December 18, 1987
  10653.  
  10654.  
  10655.  
  10656.  
  10657.  
  10658.                           - 154 -
  10659.  
  10660.  
  10661. The definition for XQueryTextExtents16 is:
  10662.  
  10663. XQueryTextExtents16(display, font_ID, string, nchars, direction_return, ascent_return,
  10664.                         descent_return, overall_return)
  10665.       Display *display;
  10666.       XID font_ID;
  10667.       XChar2b *string;
  10668.       int nchars;
  10669.       int *direction_return;
  10670.       int *ascent_return, *descent_return;
  10671.       XCharStruct *overall_return;
  10672.  
  10673.  
  10674. display   Specifies the connection to the X server.
  10675.  
  10676. font_ID   Specifies either the font ID or the graphics con-
  10677.           text that contains the font.
  10678.  
  10679. string    Specifies the character string.
  10680.  
  10681. nchars    Specifies the number of characters in the charac-
  10682.           ter string.
  10683.  
  10684. direction_returnReturns the value of the direction hint
  10685.           member:  FontLeftToRight or FontRightToLeft.
  10686.  
  10687. ascent_returnReturns the font ascent member.
  10688.  
  10689. descent_returnReturns the font descent member.
  10690.  
  10691. overall_returnReturns the overall size in the specified
  10692.           XCharStruct structure.
  10693.  
  10694. The XQueryTextExtents and XQueryTextExtents16 functions
  10695. return the logical extents of the specified 8-bit and 16-bit
  10696. character string in the specified font or the font contained
  10697. in the specified GC.  These functions query the X server
  10698. and, therefore, suffer the round trip overhead that is
  10699. avoided by XTextExtents and XTextExtents16.  Both functions
  10700. return a XCharStruct structure whose members are set to the
  10701. values discussed in the following paragraphs.
  10702.  
  10703. The ascent member is set to the maximum of the ascent
  10704. metrics of all characters in the string.  The descent member
  10705. is set to the maximum of the descent metrics.  The width
  10706. member is set to the sum of the character-width metrics of
  10707. all characters in the string.  For each character in the
  10708. string, let W be the sum of the character-width metrics of
  10709. all characters preceding it in the string.  Let L be the
  10710. left-side-bearing metric of the character plus W.  Let R be
  10711. the right-side-bearing metric of the character plus W.  The
  10712. lbearing member is set to the minimum L of all characters in
  10713. the string.  The rbearing member is the maximum R.
  10714.  
  10715.  
  10716.  
  10717.  
  10718.                      December 18, 1987
  10719.  
  10720.  
  10721.  
  10722.  
  10723.  
  10724.                           - 155 -
  10725.  
  10726.  
  10727. Note that the string formal parameter for XQueryTextEx-
  10728. tents16 is of type XChar2b, rather than of type char as in
  10729. XQueryTextExtents.  For fonts defined with linear indexing
  10730. rather than two-byte matrix indexing, the X server inter-
  10731. prets each XChar2b as a 16-bit number that has been
  10732. transmitted with the most significant byte first.  That is,
  10733. byte1 of the XChar2b is taken as the most significant byte.
  10734. If the font has no defined default character, undefined
  10735. characters in the string are taken to have all zero metrics.
  10736.  
  10737. The errors that can be generated by XQueryTextExtents and
  10738. XQueryTextExtents16 are BadGC and BadFont.
  10739.  
  10740. 6.6.  Drawing Text Characters
  10741.  
  10742. Xlib provides functions with which you can draw text charac-
  10743. ters.  This section discusses how to draw:
  10744.  
  10745. o    Complex text
  10746.  
  10747. o    Text characters
  10748.  
  10749. o    Image text characters Text Operations
  10750.  
  10751. All of the functions discussed in the following subsections
  10752. make use of fonts.  A font is a graphical description of a
  10753. set of characters that are used to increase efficiency when-
  10754. ever a set of small, similar sized patterns are repeatedly
  10755. used.
  10756.  
  10757. typedef struct {
  10758.      char *chars;             /* pointer to string */
  10759.      int nchars;              /* number of characters */
  10760.      int delta;               /* delta between strings */
  10761.      Font font;               /* Font to print it in, None don't change */
  10762. } XTextItem;
  10763.  
  10764. typedef struct {
  10765.      XChar2b *chars;          /* pointer to two byte characters */
  10766.      int nchars;              /* number of characters */
  10767.      int delta;               /* delta between strings */
  10768.      Font font;               /* font to print it in, None don't change */
  10769. } XTextItem16;
  10770.  
  10771.  
  10772. The fundamental text functions XDrawText and XDrawText16 use
  10773. these structures.  If the font member is None, the font is
  10774. changed before printing and also is stored in the GC.  If an
  10775. error was generated during text drawing, the font in the GC
  10776. is undefined.
  10777.  
  10778.  
  10779.  
  10780.  
  10781.  
  10782.  
  10783.  
  10784.                      December 18, 1987
  10785.  
  10786.  
  10787.  
  10788.  
  10789.  
  10790.                           - 156 -
  10791.  
  10792.  
  10793. 6.6.1.  Drawing Complex Text
  10794.  
  10795. Use XDrawText to draw 8-bit polytext characters or
  10796. XDrawText16 to draw 16-bit polytext characters in the speci-
  10797. fied drawable.  The definition for XDrawText is:
  10798.  
  10799. XDrawText(display, d, gc, x, y, items, nitems)
  10800.       Display *display;
  10801.       Drawable d;
  10802.       GC gc;
  10803.       int x, y;
  10804.       XTextItem *items;
  10805.       int nitems;
  10806.  
  10807.  
  10808. display   Specifies the connection to the X server.
  10809.  
  10810. d         Specifies the drawable.
  10811.  
  10812. gc        Specifies the graphics context.
  10813.  
  10814. x
  10815. y         Specify the x and y coordinates.  These coordi-
  10816.           nates define the baseline starting position for
  10817.           the character (initial character origin) and are
  10818.           relative to the origin of the specified drawable.
  10819.  
  10820. items     Specifies a pointer to an array of text items.
  10821.  
  10822. nitems    Specifies the number of text items in the array.
  10823.  
  10824.  
  10825. The definition for XDrawText16 is:
  10826.  
  10827. XDrawText16(display, d, gc, x, y, items, nitems)
  10828.       Display *display;
  10829.       Drawable d;
  10830.       GC gc;
  10831.       int x, y;
  10832.       XTextItem16 *items;
  10833.       int nitems;
  10834.  
  10835.  
  10836. display   Specifies the connection to the X server.
  10837.  
  10838. d         Specifies the drawable.
  10839.  
  10840. gc        Specifies the graphics context.
  10841.  
  10842. x
  10843. y         Specify the x and y coordinates.  These coordi-
  10844.           nates define the baseline starting position for
  10845.           the character (the initial character origin), and
  10846.           are relative to the origin of the specified
  10847.  
  10848.  
  10849.  
  10850.                      December 18, 1987
  10851.  
  10852.  
  10853.  
  10854.  
  10855.  
  10856.                           - 157 -
  10857.  
  10858.  
  10859.           drawable.
  10860.  
  10861. items     Specifies a pointer to an array of text items.
  10862.  
  10863. nitems    Specifies the number of text items in the array.
  10864.  
  10865. The XDrawText16 function is like XDrawText, except two-byte
  10866. or 16-bit characters are used.  The XDrawText and
  10867. XDrawText16 functions use the following elements in the
  10868. specified GC:  function, plane_mask, fill_style, font,
  10869. subwindow_mode, clip_x_origin, clip_y_origin, and clip_mask.
  10870. Both functions also use these graphics context mode-
  10871. dependent components: foreground, background, tile, stipple,
  10872. ts_x_origin, and ts_y_origin.
  10873.  
  10874. Each text item is processed in turn.  A font member other
  10875. than None in an item causes the font to be stored in GC and
  10876. used for subsequent text. A text element delta specifies an
  10877. additional change in the position along the x axis before
  10878. the string is drawn. The delta is always added to the char-
  10879. acter origin, and is not dependent on any characteristics of
  10880. the font.  Each character image, as defined by the font in
  10881. the GC, is treated as an additional mask for a fill opera-
  10882. tion on the drawable.  If a text item generates a BadFont
  10883. error, the previous text items may have been drawn.
  10884.  
  10885. Note that the chars member of the XTextItem16 structure is
  10886. of type XChar2b, rather than of type char as it is in the
  10887. XTextItem structure.  For fonts defined with linear indexing
  10888. rather than two-byte matrix indexing, the X server will
  10889. interpret each member of the XChar2b structure as a 16-bit
  10890. number that has been transmitted most significant byte
  10891. first.  In other words, the byte1 member of the XChar2b
  10892. structure is taken as the most significant byte.
  10893.  
  10894. The errors that can be generated by XDrawText and
  10895. XDrawText16 are BadDrawable, BadGC, BadFont, and BadMatch.
  10896.  
  10897. 6.6.2.  Drawing Text Characters
  10898.  
  10899. Use XDrawString to draw 8-bit text characters or XDraw-
  10900. String16 to draw 16-bit characters in the specified draw-
  10901. able.  The definition for XDrawString is:
  10902.  
  10903. XDrawString(display, d, gc, x, y, string, length)
  10904.       Display *display;
  10905.       Drawable d;
  10906.       GC gc;
  10907.       int x, y;
  10908.       char *string;
  10909.       int length;
  10910.  
  10911.  
  10912.  
  10913.  
  10914.  
  10915.  
  10916.                      December 18, 1987
  10917.  
  10918.  
  10919.  
  10920.  
  10921.  
  10922.                           - 158 -
  10923.  
  10924.  
  10925. display   Specifies the connection to the X server.
  10926.  
  10927. d         Specifies the drawable.
  10928.  
  10929. gc        Specifies the graphics context.
  10930.  
  10931. x
  10932. y         Specify the x and y coordinates.  These coordi-
  10933.           nates define the baseline starting position for
  10934.           the character (initial character origin) and are
  10935.           relative to the origin of the specified drawable.
  10936.  
  10937. string    Specifies the character string.
  10938.  
  10939. length    Specifies the number of characters in the string
  10940.           argument.
  10941.  
  10942.  
  10943. The definition for XDrawString16 is:
  10944.  
  10945. XDrawString16(display, d, gc, x, y, string, length)
  10946.       Display *display;
  10947.       Drawable d;
  10948.       GC gc;
  10949.       int x, y;
  10950.       XChar2b *string;
  10951.       int length;
  10952.  
  10953.  
  10954. display   Specifies the connection to the X server.
  10955.  
  10956. d         Specifies the drawable.
  10957.  
  10958. gc        Specifies the graphics context.
  10959.  
  10960. x
  10961. y         Specify the x and y coordinates.  These coordi-
  10962.           nates define the baseline starting position for
  10963.           the character (the initial character origin), and
  10964.           are relative to the origin of the specified draw-
  10965.           able.
  10966.  
  10967. string    Specifies the character string.
  10968.  
  10969. length    Specifies the number of characters in the string
  10970.           argument.
  10971.  
  10972.  
  10973. The XDrawString and XDrawString16 functions use these graph-
  10974. ics context components: function, plane_mask, fill_style,
  10975. font, subwindow_mode, clip_x_origin, clip_y_origin, and
  10976. clip_mask.  Both functions also use these graphics context
  10977. mode-dependent components: foreground, background, tile,
  10978. stipple, ts_x_origin, and ts_y_origin.  Each character
  10979.  
  10980.  
  10981.  
  10982.                      December 18, 1987
  10983.  
  10984.  
  10985.  
  10986.  
  10987.  
  10988.                           - 159 -
  10989.  
  10990.  
  10991. image, as defined by the font in the GC, is treated as an
  10992. additional mask for a fill operation on the drawable.
  10993.  
  10994. The errors that can be generated by XDrawString and XDraw-
  10995. String16 are BadDrawable, BadGC, BadFont, and BadMatch.
  10996.  
  10997. 6.6.3.  Drawing Image Text Characters
  10998.  
  10999. Some applications, in particular terminal emulators, need to
  11000. print image text in which both the foreground and background
  11001. bits of each character are painted.  This avoids annoying
  11002. flicker on many displays.  Use XDrawImageString to draw 8-
  11003. bit or XDrawImageString16 to draw 16-bit image text charac-
  11004. ters in the specified drawable.  These functions also modify
  11005. both the foreground and background pixels in the characters.
  11006. The definition for XDrawImageString is:
  11007.  
  11008. XDrawImageString(display, d, gc, x, y, string, length)
  11009.       Display *display;
  11010.       Drawable d;
  11011.       GC gc;
  11012.       int x, y;
  11013.       char *string;
  11014.       int length;
  11015.  
  11016.  
  11017. display   Specifies the connection to the X server.
  11018.  
  11019. d         Specifies the drawable.
  11020.  
  11021. gc        Specifies the graphics context.
  11022.  
  11023. x
  11024. y         Specify the x and y coordinates.  These coordi-
  11025.           nates define the baseline starting position for
  11026.           the image text character (initial character ori-
  11027.           gin) and are relative to the origin of the speci-
  11028.           fied drawable.
  11029.  
  11030. string    Specifies the character string.
  11031.  
  11032. length    Specifies the number of characters in the string
  11033.           argument.
  11034.  
  11035.  
  11036. The definition for XDrawImageString16 is:
  11037.  
  11038. XDrawImageString16(display, d, gc, x, y, string, length)
  11039.       Display *display;
  11040.       Drawable d;
  11041.       GC gc;
  11042.       int x, y;
  11043.       XChar2b *string;
  11044.       int length;
  11045.  
  11046.  
  11047.  
  11048.                      December 18, 1987
  11049.  
  11050.  
  11051.  
  11052.  
  11053.  
  11054.                           - 160 -
  11055.  
  11056.  
  11057. display   Specifies the connection to the X server.
  11058.  
  11059. d         Specifies the drawable.
  11060.  
  11061. gc        Specifies the graphics context.
  11062.  
  11063. x
  11064. y         Specify the x and y coordinates.  These coordi-
  11065.           nates define the baseline starting position for
  11066.           the image text character and are relative to the
  11067.           origin of the specified drawable.
  11068.  
  11069. string    Specifies the character string.
  11070.  
  11071. length    Specifies the number of characters in the string
  11072.           argument.
  11073.  
  11074. The XDrawImageText16 function is like XDrawImageText, except
  11075. two-byte or 16-bit characters are used.  XDrawImageString
  11076. and XDrawImageString16 use these graphics context com-
  11077. ponents: plane_mask, foreground, background, font,
  11078. subwindow_mode, clip_x_origin, clip_y_origin, and clip_mask.
  11079. The effect is first to fill a destination rectangle with the
  11080. background pixel defined in the GC and then to paint the
  11081. text with the foreground pixel.  The upper left corner of
  11082. the filled rectangle is at:
  11083.  
  11084.      [x + overall->lbearing, y - font_ascent]
  11085.  
  11086. The width is at:
  11087.  
  11088.      overall->rbearing - overall->lbearing
  11089.  
  11090. The height is at:
  11091.  
  11092.      font_ascent + font_descent
  11093.  
  11094. The overall->lbearing, overall->rbearing, font_ascent, and
  11095. font_descent are as would be returned by XQueryTextExtents
  11096. using gc and string.  The function and fill_style defined in
  11097. the GC are ignored for these functions. The effective func-
  11098. tion is GXcopy, and the effective fill_style is FillSolid.
  11099.  
  11100. Note that the string formal parameter for XDrawImageString16
  11101. is of type XChar2b, rather than of type char as in XDrawIm-
  11102. ageString.  For fonts defined with linear indexing rather
  11103. than two-byte matrix indexing, the X server interprets each
  11104. XChar2b as a 16-bit number that has been transmitted with
  11105. the most significant byte first.  In other words, the byte1
  11106. member of the XChar2b structure is taken as the most signi-
  11107. ficant byte.
  11108.  
  11109. The errors that can be generated by XDrawImageString and
  11110. XDrawImageString16 are BadDrawable, BadGC, and BadMatch.
  11111.  
  11112.  
  11113.  
  11114.                      December 18, 1987
  11115.  
  11116.  
  11117.  
  11118.  
  11119.  
  11120.                           - 161 -
  11121.  
  11122.  
  11123. 6.7.  Transferring Images Between Client and Server
  11124.  
  11125. Xlib provides functions with which you can transfer images
  11126. between a client and the server.  Because the server may
  11127. require diverse data formats, Xlib provides an image object
  11128. that fully describes the data in memory and that provides
  11129. for basic operations on that data. You should reference the
  11130. data through the image object, not the data directly.  How-
  11131. ever, some implementations of the Xlib library may effi-
  11132. ciently deal with frequently used data formats by replacing
  11133. routines in the procedure vector with special case routines.
  11134. Supported operations include destroying the image, getting a
  11135. pixel, storing a pixel, extracting a sub image of an image,
  11136. and adding a constant to an image.
  11137.  
  11138.                             Note
  11139.  
  11140.      See Chapter 10 for further information about these
  11141.      utility functions. Chapter 10 also has information
  11142.      about additional library functions used to perform
  11143.      basic operations on an image.
  11144.  
  11145.  
  11146. All the image manipulation functions discussed in this sec-
  11147. tion make use of the XImage data structure.  The members in
  11148. the XImage structure are:
  11149.  
  11150. typedef struct _XImage {
  11151.      int width, height;       /* size of image */
  11152.      int xoffset;             /* number of pixels offset in X direction */
  11153.      int format;              /* XYBitmap, XYPixmap, ZPixmap */
  11154.      char *data;              /* pointer to image data */
  11155.      int byte_order;          /* data byte order, LSBFirst, MSBFirst */
  11156.      int bitmap_unit;         /* quant. of scanline 8, 16, 32 */
  11157.      int bitmap_bit_order;    /* LSBFirst, MSBFirst */
  11158.      int bitmap_pad;          /* 8, 16, 32 either XY or ZPixmap */
  11159.      int depth;               /* depth of image */
  11160.      int bytes_per_line;      /* accelerator to next line */
  11161.      int bits_per_pixel;      /* bits per pixel (ZPixmap) */
  11162.      unsigned long red_mask;  /* bits in z arrangement */
  11163.      unsigned long green_mask;
  11164.      unsigned long blue_mask;
  11165.      char *obdata;            /* hook for the object routines to hang on */
  11166.      struct funcs {           /* image manipulation routines */
  11167.           struct _XImage *(*create_image)();
  11168.           int (*destroy_image)();
  11169.           unsigned long (*get_pixel)();
  11170.           int (*put_pixel)();
  11171.           struct _XImage *(*sub_image)();
  11172.           int (*add_pixel)();
  11173.           } f;
  11174. } XImage;
  11175.  
  11176.  
  11177.  
  11178.  
  11179.  
  11180.                      December 18, 1987
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186.                           - 162 -
  11187.  
  11188.  
  11189. The XImage structure describes an image as it exists in the
  11190. client's memory. The user may request that some of the
  11191. members (for example, height, width, and xoffset) be changed
  11192. when the image is sent to the server. That is, the user may
  11193. send a subset of the image.  Other members (for example,
  11194. byte_order, bitmap_unit, and so forth) are characteristics
  11195. of both the image and of the server. If these members differ
  11196. between the image and the server, XPutImage makes the
  11197. appropriate conversions.  If the image is formatted as an
  11198. XYPixmap, (that is, the format member is set to the constant
  11199. XYPixmap), the the first byte of the first line of plane n
  11200. is located at the address (data + (n * height *
  11201. bytes_per_line)).
  11202.  
  11203.  
  11204. Use XPutImage to combine an image in memory with a rectangle
  11205. of a drawable on your display.  The definition for this
  11206. function is:
  11207.  
  11208. XPutImage(display, d, gc, image, src_x, src_y, dst_x, dst_y, width, height)
  11209.         Display *display;
  11210.         Drawable d;
  11211.         GC gc;
  11212.         XImage *image;
  11213.         int src_x, src_y;
  11214.         int dst_x, dst_y;
  11215.         unsigned int width, height;
  11216.  
  11217.  
  11218. display   Specifies the connection to the X server.
  11219.  
  11220. d         Specifies the drawable.
  11221.  
  11222. gc        Specifies the graphics context.
  11223.  
  11224. image     Specifies the image you want combined with the
  11225.           rectangle.
  11226.  
  11227. src_x     Specifies the offset in X from the left edge of
  11228.           the image defined by the XImage data structure.
  11229.  
  11230. src_y     Specifies the offset in from the top edge of the
  11231.           image defined by the XImage data structure.
  11232.  
  11233. dst_x
  11234. dst_y     Specify the x and y coordinates.  These are the
  11235.           coordinates of the subimage and are relative to
  11236.           the origin of the drawable where the image will be
  11237.           drawn.
  11238.  
  11239. width
  11240. height    Specify the width and height.  These are of the
  11241.           subimage.  These arguments define the dimensions
  11242.           of the rectangle.
  11243.  
  11244.  
  11245.  
  11246.                      December 18, 1987
  11247.  
  11248.  
  11249.  
  11250.  
  11251.  
  11252.                           - 163 -
  11253.  
  11254.  
  11255. The XPutImage function combines an image in memory with a
  11256. rectangle of the specified drawable.  The function uses
  11257. these graphics context components: function, plane_mask,
  11258. subwindow_mode, clip_x_origin, clip_y_origin, and clip_mask.
  11259. This function also uses the graphics context mode-dependent
  11260. components foreground and background.  If XYBitmap format is
  11261. used, the depth must be one, and the image must be XYFormat.
  11262. Otherwise, a BadMatch error is generated.  The foreground
  11263. pixel in the GC defines the source for one bits in the
  11264. image, and the background pixel defines the source for the
  11265. zero bits.  For XYPixmap and ZPixmap, the depth must match
  11266. the depth of drawable. Otherwise, a BadMatch error is gen-
  11267. erated.  For XYPixmap, the image must be sent in XYFormat.
  11268. For ZPixmap, the image must be sent in the ZFormat defined
  11269. for the given depth.  The section of the image defined by
  11270. the src_x, src_y, width, and height arguments are drawn on
  11271. the specified part of the drawable.
  11272.  
  11273. The errors that can be generated by XPutImage are BadDraw-
  11274. able, BadGC, BadValue, and BadMatch.
  11275.  
  11276.  
  11277. Use XGetImage to return the contents of a rectangle in the
  11278. specified drawable on the display.  This function is
  11279. intended specifically for rudimentary hardcopy support.  The
  11280. definition for this function is:
  11281.  
  11282. XImage *XGetImage(display, d, x, y, width, height, plane_mask, format)
  11283.         Display *display;
  11284.         Drawable d;
  11285.         int x, y;
  11286.         unsigned int width, height;
  11287.         long plane_mask;
  11288.         int format;
  11289.  
  11290.  
  11291. display   Specifies the connection to the X server.
  11292.  
  11293. d         Specifies the drawable.
  11294.  
  11295. x
  11296. y         Specify the x and y coordinates.  These coordi-
  11297.           nates define the upper left corner of the rectan-
  11298.           gle and are relative to the origin of the draw-
  11299.           able.
  11300.  
  11301. width
  11302. height    Specify the width and height of the subimage.
  11303.           These arguments define the dimensions of the rec-
  11304.           tangle.
  11305.  
  11306. plane_maskSpecifies the plane mask.
  11307.  
  11308.  
  11309.  
  11310.  
  11311.  
  11312.                      December 18, 1987
  11313.  
  11314.  
  11315.  
  11316.  
  11317.  
  11318.                           - 164 -
  11319.  
  11320.  
  11321. format    Specifies the format for the image.  You can pass
  11322.           one of these constants:  XYPixmap or ZPixmap.
  11323.  
  11324. The XGetImage function returns the XImage structure.  This
  11325. structure provides you with the contents of the specified
  11326. rectangle of the drawable in the format you specify.  If the
  11327. format argument is XYPixmap, the function transmits only the
  11328. bit planes you passed to the plane_mask argument.  If the
  11329. plane_mask argument only requests a subset of the planes of
  11330. the display, the depth of the returned image will be the
  11331. number of planes requested.  If the format argument is ZPix-
  11332. map, the function transmits as zero the bits in all planes
  11333. not specified in the plane_mask argument.  The function per-
  11334. forms no range checking on the values in plane_mask and
  11335. ignores extraneous bits.
  11336.  
  11337. XGetImage returns the depth of the image to the depth member
  11338. of the XImage structure.  The depth of the image is as
  11339. specified when the drawable was created.
  11340.  
  11341. If the drawable is a pixmap, then the given rectangle must
  11342. be wholly contained within the pixmap, otherwise the X
  11343. server will generate a BadMatch error.  If the drawable is a
  11344. window, the window must be mapped, and if there were no
  11345. inferiors or overlapping windows, the specified rectangle of
  11346. the window would be fully visible on the screen and wholly
  11347. contained within the outside edges of the window.  Other-
  11348. wise, a BadMatch error is generated.  Note that the borders
  11349. of the window can be included and read with this request.
  11350. If the window has a backing-store, the backing-store con-
  11351. tents are returned for regions of the window that are
  11352. obscured by noninferior windows. Otherwise, the return con-
  11353. tents of such obscured regions are undefined.  Also unde-
  11354. fined are the returned contents of visible regions of infe-
  11355. riors of different depth than the specified window.
  11356.  
  11357. The errors that can be generated by XGetImage are BadDraw-
  11358. able, BadValue, and BadMatch.
  11359.  
  11360. Use XGetSubImage to copy the contents of a rectangle in the
  11361. specified drawable on the display to the specified location
  11362. within a pre-existing image structure.  The definition for
  11363. this function is:
  11364.  
  11365. XImage *XGetSubImage(display, d, x, y, width, height, plane_mask, format, dest_image, dest_x, dest_y)
  11366.       Display *display;
  11367.       Drawable d;
  11368.       int x, y;
  11369.       unsigned int width, height;
  11370.       unsigned long plane_mask;
  11371.       int format;
  11372.       XImage *dest_image;
  11373.       int dest_x, dest_y;
  11374.  
  11375.  
  11376.  
  11377.  
  11378.                      December 18, 1987
  11379.  
  11380.  
  11381.  
  11382.  
  11383.  
  11384.                           - 165 -
  11385.  
  11386.  
  11387. display   Specifies the connection to the X server.
  11388.  
  11389. d         Specifies the drawable.
  11390.  
  11391. x
  11392. y         Specify the x and y coordinates.  These coordi-
  11393.           nates define the upper left corner of the rectan-
  11394.           gle and are relative to the origin of the draw-
  11395.           able.
  11396.  
  11397. width
  11398. height    Specify the width and height of the subimage.
  11399.           These arguments define the dimensions of the rec-
  11400.           tangle.
  11401.  
  11402. plane_maskSpecifies the plane mask.
  11403.  
  11404. format    Specifies the format for the image.  You can pass
  11405.           one of these constants:  XYPixmap or ZPixmap.
  11406.  
  11407. dest_imageSpecify the the destination image.
  11408.  
  11409. dest_x
  11410. dest_y    Specify the x and y coordinates of the destination
  11411.           rectangle relative to its origin.  These coordi-
  11412.           nates specify the upper left corner of the desti-
  11413.           nation rectangle.  These coordinates determine
  11414.           where the subimage will be placed within the des-
  11415.           tination image.
  11416.  
  11417. The XGetSubImage function updates the Image with the speci-
  11418. fied subimage in the same manner as XGetImage.  If the for-
  11419. mat argument is XYPixmap, the function transmits only the
  11420. bit planes you passed to the plane_mask argument.  If the
  11421. format argument is ZPixmap, the function transmits as zero
  11422. the bits in all planes not specified in the plane_mask argu-
  11423. ment.  The function performs no range checking on the values
  11424. in plane_mask and ignores extraneous bits.
  11425.  
  11426. XGetSubImage does not update any fields in the destination
  11427. XImage structure.  The depth of the destination XImage
  11428. structure must be the same as that of the drawable.  Other-
  11429. wise, a BadImage error is generated.  If the specified
  11430. subimage does not fit at the specified location on the des-
  11431. tination image, the right and bottom edges are clipped.  If
  11432. the drawable is a window, the window must be mapped, and it
  11433. must be the case that, if there were no inferiors or over-
  11434. lapping windows, the specified rectangle of the window would
  11435. be fully visible on the screen.  Otherwise, a BadMatch error
  11436. is generated.  If the window has a backing-store, then the
  11437. backing-store contents are returned for regions of the win-
  11438. dow that are obscured by noninferior windows. Otherwise, the
  11439. return contents of such obscured regions are undefined.
  11440. Also undefined are the returned contents of visible regions
  11441.  
  11442.  
  11443.  
  11444.                      December 18, 1987
  11445.  
  11446.  
  11447.  
  11448.  
  11449.  
  11450.                           - 166 -
  11451.  
  11452.  
  11453. of inferiors of different depth than the specified window.
  11454.  
  11455. The errors that can be generated by XGetSubImage are Bad-
  11456. Drawable, BadGC, BadValue, and BadMatch.
  11457.  
  11458. 6.8.  Manipulating Cursors
  11459.  
  11460. Xlib provides functions with which you can manipulate the
  11461. cursor.  This section discusses how to:
  11462.  
  11463. o    Create a cursor
  11464.  
  11465. o    Change or destroy a cursor
  11466.  
  11467. o    Define the cursor for a window Cursors
  11468.  
  11469. These functions allow you to load and change cursors associ-
  11470. ated with windows.  Each window can have a different cursor
  11471. defined for it.  Whenever the pointer is in a visible win-
  11472. dow, it will be set to the cursor defined for that window.
  11473. If no cursor was defined for that window, the cursor will be
  11474. the that defined for the parent window.
  11475.  
  11476. From X's perspective, a cursor consists of a cursor shape,
  11477. mask, colors for the shape and mask, and ``hot spot''. The
  11478. cursor pixmap determines the shape of the cursor and must be
  11479. a depth of one (1).  The mask pixmap determines the bits
  11480. which will be modified by the cursor.  The colors determine
  11481. the colors of the shape and mask.  The hot spot defines the
  11482. point on the cursor which will be reported when a pointer
  11483. event occurs.  There may be and probably are limitations
  11484. imposed by the hardware on cursors as to size and whether a
  11485. mask is implemented. XQueryBestCursor can be used to find
  11486. out what sizes are possible.  In the future, it is intended
  11487. that most standard cursors will be stored as a special font.
  11488. Client programs refer to cursors by using Cursor resource
  11489. IDs.
  11490.  
  11491. 6.8.1.  Creating a Cursor
  11492.  
  11493. Xlib provides functions with which you can create a font,
  11494. bitmap, or glyph cursor.
  11495.  
  11496.  
  11497. Use XCreateFontCursor to create a cursor from a standard
  11498. font.  XRecolorCursor defined in the next section can be
  11499. used to change the color of the cursor to the desired
  11500. colors.  The definition for this function is:
  11501.  
  11502. #include <X11/cursorfont.h>
  11503. Cursor XCreateFontCursor(display, shape)
  11504.       Display *display;
  11505.       unsigned int shape;
  11506.  
  11507.  
  11508.  
  11509.                      December 18, 1987
  11510.  
  11511.  
  11512.  
  11513.  
  11514.  
  11515.                           - 167 -
  11516.  
  11517.  
  11518. display   Specifies the connection to the X server.
  11519.  
  11520. shape     Specifies the shape in which you want to create
  11521.           the standard cursor.
  11522.  
  11523. X provides a set of standard cursor shapes in a special font
  11524. named cursorfont.  Applications are encouraged to use this
  11525. interface for their cursors because the font can be custom-
  11526. ized for the individual display type.  The shape argument
  11527. specifies which glyph of the standard fonts to use.
  11528.  
  11529. The hotspot comes from the information stored in the cursor
  11530. font.  The initial colors of a cursor are a black foreground
  11531. and a white background.  See Appendix C for further informa-
  11532. tion about cursors and their shapes in fonts.
  11533.  
  11534. The errors that can be generated by XCreateFontCursor are
  11535. BadAlloc, BadMatch, and BadValue.
  11536.  
  11537.  
  11538. Use XCreatePixmapCursor to create a cursor from two bitmaps.
  11539. The definition for this function is:
  11540.  
  11541. Cursor XCreatePixmapCursor(display, source, mask, foreground_color, background_color, x, y)
  11542.       Display *display;
  11543.       Pixmap source;
  11544.       Pixmap mask;
  11545.       XColor *foreground_color;
  11546.       XColor *background_color;
  11547.       unsigned int x, y;
  11548.  
  11549.  
  11550. display   Specifies the connection to the X server.
  11551.  
  11552. source    Specifies the shape of the source cursor.
  11553.  
  11554. mask      Specifies the source bits of the cursor that are
  11555.           to be displayed.  You can pass the constant None.
  11556.  
  11557. foreground_colorSpecifies the red, green, and blue (RGB)
  11558.           values for the foreground of the source.
  11559.  
  11560. background_colorSpecifies the red, green, and blue (RGB)
  11561.           values for the background of the source.
  11562.  
  11563. x
  11564. y         Specify the x and y coordinates.  These coordi-
  11565.           nates indicate the hot spot relative to the
  11566.           source's origin and must be a point within the
  11567.           source. Otherwise, a BadMatch error is generated.
  11568.  
  11569. The XCreatePixmapCursor function creates a cursor and
  11570. returns the cursor ID associated with it.  The foreground
  11571. and background RGB values must be specified using
  11572.  
  11573.  
  11574.  
  11575.                      December 18, 1987
  11576.  
  11577.  
  11578.  
  11579.  
  11580.  
  11581.                           - 168 -
  11582.  
  11583.  
  11584. foreground_color and background_color, even if the X server
  11585. only has a StaticGray or GrayScale screen.  The foreground
  11586. color is used for the one bits in the source, and the back-
  11587. ground color is used for the zero bits.  Both source and
  11588. mask, if specified, must have depth one but can have any
  11589. root.  Otherwise, a BadMatch error is generated. The mask
  11590. argument defines the shape of the cursor; that is, the one
  11591. bits in the mask define which source pixels will be
  11592. displayed, where the mask has zero bits, the corresponding
  11593. bits of the source pixmap are ignored.  If no mask is given,
  11594. all pixels of the source are displayed.  The mask, if
  11595. present, must be the same size as the pixmap defined by the
  11596. source argument. Otherwise, a BadMatch error is generated.
  11597.  
  11598. The components of the cursor may be transformed arbitrarily
  11599. to meet display limitations.  The pixmaps can be freed
  11600. immediately if no further explicit references to them are to
  11601. be made.  Subsequent drawing in the source or mask pixmap
  11602. has an undefined effect on the cursor.  The X server might
  11603. or might not make a copy of the pixmap.
  11604.  
  11605. The other event errors that can be generated by XCreatePix-
  11606. mapCursor are BadAlloc and BadPixmap.
  11607.  
  11608.  
  11609. Use XCreateGlyphCursor to create a cursor from font glyphs.
  11610. This is a fundamental request used by XCreateFontCursor.
  11611. The definition for XCreateGlyphCursor is:
  11612.  
  11613. Cursor XCreateGlyphCursor(display, source_font, mask_font, source_char, mask_char, foreground_color,
  11614. background_color)
  11615.       Display *display;
  11616.       Font source_font, mask_font;
  11617.       unsigned int source_char, mask_char;
  11618.       XColor *foreground_color;
  11619.       XColor *background_color;
  11620.  
  11621.  
  11622. display   Specifies the connection to the X server.
  11623.  
  11624. source_fontSpecifies the font for the source glyph.
  11625.  
  11626. mask_font Specifies the font for the mask glyph. You can
  11627.           pass the constant None.
  11628.  
  11629. source_charSpecifies the character glyph for the source.
  11630.  
  11631. mask_char Specifies the glyph character for the mask.
  11632.  
  11633. foreground_colorSpecifies the red, green, and blue (RGB)
  11634.           values for the foreground of the source.
  11635.  
  11636.  
  11637.  
  11638.  
  11639.  
  11640.  
  11641.                      December 18, 1987
  11642.  
  11643.  
  11644.  
  11645.  
  11646.  
  11647.                           - 169 -
  11648.  
  11649.  
  11650. background_colorSpecifies the red, green, and blue (RGB)
  11651.           values for the background of the source.
  11652.  
  11653. The XCreateGlyphCursor function is similar to XCreatePixmap-
  11654. Cursor and creates a cursor from font glyphs.  For
  11655. XCreateGlyphCursor, however, the source and mask bitmaps are
  11656. obtained from the specified font glyphs.  The source_char
  11657. must be a defined glyph in source_font, and, if mask_font is
  11658. given, mask_char must be a defined glyph in mask_font. Oth-
  11659. erwise, a BadValue error is generated.  The mask_font and
  11660. character are optional.  The origins of the source_char and
  11661. mask_char (if defined) glyphs are positioned coincidently
  11662. and define the hotspot. The source_char and mask_char need
  11663. not have the same bounding box metrics, and there is no res-
  11664. triction on the placement of the hotspot relative to the
  11665. bounding boxes. If no mask_char is given, all pixels of the
  11666. source are displayed.  You can free the fonts immediately by
  11667. calling XFreeFont if no further explicit references to them
  11668. are to be made.
  11669.  
  11670. Note that schar and mchar are of type unsigned int, not of
  11671. type XChar2b.  For two-byte matrix fonts, the 16-bit value
  11672. should be formed with the byte1 member in the most signifi-
  11673. cant byte and the byte2 member in the least significant
  11674. byte.
  11675.  
  11676. The other event errors that can be generated by
  11677. XCreateGlyphCursor are BadAlloc, BadFont, and BadValue.
  11678.  
  11679. 6.8.2.  Changing and Destroying Cursors
  11680.  
  11681. Xlib provides functions with which you can change the cursor
  11682. color, destroy the cursor, and determine the cursor size.
  11683.  
  11684.  
  11685. Use XRecolorCursor to change the color of the specified cur-
  11686. sor.  The definition for this function is:
  11687.  
  11688. XRecolorCursor(display, cursor, foreground_color, background_color)
  11689.       Display *display;
  11690.       Cursor cursor;
  11691.       XColor *foreground_color, *background_color;
  11692.  
  11693.  
  11694. display   Specifies the connection to the X server.
  11695.  
  11696. cursor    Specifies the cursor.
  11697.  
  11698. foreground_colorSpecifies the red, green, and blue (RGB)
  11699.           values for the foreground of the source.
  11700.  
  11701. background_colorSpecifies the red, green, and blue (RGB)
  11702.           values for the background of the source.
  11703.  
  11704.  
  11705.  
  11706.  
  11707.                      December 18, 1987
  11708.  
  11709.  
  11710.  
  11711.  
  11712.  
  11713.                           - 170 -
  11714.  
  11715.  
  11716. The XRecolorCursor function changes the color of the speci-
  11717. fied cursor, and, if the cursor is being displayed on a
  11718. screen, the change is visible immediately.
  11719.  
  11720. The error that can be generated by XRecolorCursor is BadCur-
  11721. sor.
  11722.  
  11723.  
  11724. Use XFreeCursor to free (destroy) the specified cursor.  The
  11725. definition for this function is:
  11726.  
  11727. XFreeCursor(display, cursor)
  11728.       Display *display;
  11729.       Cursor cursor;
  11730.  
  11731.  
  11732. display   Specifies the connection to the X server.
  11733.  
  11734. cursor    Specifies the cursor.
  11735.  
  11736. The XFreeCursor function deletes the association between the
  11737. cursor resource ID and the specified cursor.  The cursor
  11738. storage is freed when no other resource references it.  The
  11739. specified cursor ID should not be referred to again or an
  11740. error will be generated.
  11741.  
  11742. The error that can be generated by XFreeCursor is BadCursor.
  11743.  
  11744.  
  11745. Use XQueryBestCursor to determine useful cursor sizes.  The
  11746. definition for this function is:
  11747.  
  11748. Status XQueryBestCursor(display, d, width, height, width_return, height_return)
  11749.       Display *display;
  11750.       Drawable d;
  11751.       unsigned int width, height;
  11752.       unsigned int *width_return, *height_return;
  11753.  
  11754.  
  11755. display   Specifies the connection to the X server.
  11756.  
  11757. d         Specifies the drawable. The drawable indicates the
  11758.           desired screen.
  11759.  
  11760. width
  11761. height    Specify the width and height of the cursor that
  11762.           you want the size information for.
  11763.  
  11764. width_return
  11765. height_returnReturns the best width and height (that is,
  11766.           closest to the specified width and height).
  11767.  
  11768. Some displays allow larger cursors than other displays.
  11769. XQueryBestCursor provides a way to find out what size
  11770.  
  11771.  
  11772.  
  11773.                      December 18, 1987
  11774.  
  11775.  
  11776.  
  11777.  
  11778.  
  11779.                           - 171 -
  11780.  
  11781.  
  11782. cursors are actually possible on the display.  This function
  11783. returns the largest size that can be displayed.  For a cur-
  11784. sor shape, it returns a bitmap shape acceptable for
  11785. XCreatePixmapCursor.  Applications should be prepared to use
  11786. smaller cursors on displays which cannot support large ones.
  11787.  
  11788. The error that can be generated by XQueryBestCursor is Bad-
  11789. Drawable.
  11790.  
  11791. 6.8.3.  Defining the Cursor
  11792.  
  11793. Xlib provides functions with which you can define or unde-
  11794. fine the cursor in a window.
  11795.  
  11796.  
  11797. Use XDefineCursor to define which cursor will be used in a
  11798. window.  The definition for this function is:
  11799.  
  11800. XDefineCursor(display, w, cursor)
  11801.       Display *display;
  11802.       Window w;
  11803.       Cursor cursor;
  11804.  
  11805.  
  11806. display   Specifies the connection to the X server.
  11807.  
  11808. w         Specifies the window ID.
  11809.  
  11810. cursor    Specifies the cursor that is to be displayed when
  11811.           the pointer is in the specified window.  You can
  11812.           pass None if no cursor is to be displayed.
  11813.  
  11814. If a cursor is set, it will be used when the pointer is in
  11815. the window.
  11816.  
  11817. The errors that can be generated by XDefineCursor are
  11818. BadWindow, BadAlloc, and BadCursor.
  11819.  
  11820.  
  11821. Use XUndefineCursor to undefine the mouse cursor in the
  11822. specified window.  The definition for this function is:
  11823.  
  11824. XUndefineCursor(display, w)
  11825.       Display *display;
  11826.       Window w;
  11827.  
  11828.  
  11829. display   Specifies the connection to the X server.
  11830.  
  11831. w         Specifies the window ID.
  11832.  
  11833. The XUndefineCursor undoes the effect of a previous XDe-
  11834. fineCursor for this window.  When the mouse is in the win-
  11835. dow, the parent's cursor will now be used.  On the root
  11836.  
  11837.  
  11838.  
  11839.                      December 18, 1987
  11840.  
  11841.  
  11842.  
  11843.  
  11844.  
  11845.                           - 172 -
  11846.  
  11847.  
  11848. window, with no cursor specified, the default cursor is
  11849. restored.
  11850.  
  11851. The error that can be generated by XUndefineCursor is
  11852. BadWindow.
  11853.  
  11854.  
  11855.  
  11856.  
  11857.  
  11858.  
  11859.  
  11860.  
  11861.  
  11862.  
  11863.  
  11864.  
  11865.  
  11866.  
  11867.  
  11868.  
  11869.  
  11870.  
  11871.  
  11872.  
  11873.  
  11874.  
  11875.  
  11876.  
  11877.  
  11878.  
  11879.  
  11880.  
  11881.  
  11882.  
  11883.  
  11884.  
  11885.  
  11886.  
  11887.  
  11888.  
  11889.  
  11890.  
  11891.  
  11892.  
  11893.  
  11894.  
  11895.  
  11896.  
  11897.  
  11898.  
  11899.  
  11900.  
  11901.  
  11902.  
  11903.  
  11904.  
  11905.                      December 18, 1987
  11906.  
  11907.  
  11908.  
  11909.  
  11910.  
  11911.                           - 173 -
  11912.  
  11913.  
  11914.  
  11915.  
  11916.                          Chapter 7
  11917.  
  11918.                   Window Manager Functions
  11919.  
  11920.  
  11921.  
  11922. Chapter 7 - Window Manager Functions Once you have connected
  11923. the display to the X server and want to create a window
  11924. manager application, you can use the Xlib window manager
  11925. functions to:
  11926.  
  11927. o    Change the parent of a window
  11928.  
  11929. o    Control the lifetime of a window
  11930.  
  11931. o    Manipulate color maps
  11932.  
  11933. o    Manipulate the pointer
  11934.  
  11935. o    Manipulate the keyboard
  11936.  
  11937. o    Grab the server
  11938.  
  11939. o    Control processing
  11940.  
  11941. o    Manipulate the keyboard encoding
  11942.  
  11943. o    Manipulate the screen saver
  11944.  
  11945. o    Control host access
  11946.  
  11947.                             Note
  11948.  
  11949.      The functions in this chapter are most often used
  11950.      by window managers, though it can be difficult to
  11951.      definitively categorize functions as application
  11952.      only or window manager only.  It is not expected
  11953.      that these functions will be used by most normal
  11954.      application programs.
  11955.  
  11956.  
  11957. 7.1.  Changing the Parent of a Window
  11958.  
  11959. Use XReparentWindow to change a window's parent within a
  11960. single screen.  There is no way to move a window between
  11961. screens.  The definition for this function is:
  11962.  
  11963. XReparentWindow(display, w, parent, x, y)
  11964.       Display *display;
  11965.       Window w;
  11966.       Window parent;
  11967.       int x, y;
  11968.  
  11969.  
  11970.  
  11971.                      December 18, 1987
  11972.  
  11973.  
  11974.  
  11975.  
  11976.  
  11977.                           - 174 -
  11978.  
  11979.  
  11980. display   Specifies the connection to the X server.
  11981.  
  11982. w         Specifies the window ID.
  11983.  
  11984. parent    Specifies the parent window ID.
  11985.  
  11986. x
  11987. y         Specify the x and y coordinates of the position in
  11988.           the new parent window of the specified window.
  11989.  
  11990. The XReparentWindow function reparents the specified window
  11991. by inserting it as the child of the specified parent.  If
  11992. the window is mapped, XReparentWindow automatically performs
  11993. an XUnmapWindow request on the specified window.  The func-
  11994. tion then removes the specified window from its current
  11995. position in the hierarchy and inserts it as the child of the
  11996. specified parent.  The window is placed on top in the stack-
  11997. ing order with respect to sibling windows.
  11998.  
  11999. After reparenting the specified window, XReparentWindow
  12000. causes the X server to generate a ReparentNotify event.  The
  12001. override_redirect member of the structure returned by this
  12002. event is set to either True or False.  Window manager
  12003. clients normally should ignore this event if this member is
  12004. set to True.  See Chapter 8 for more information on
  12005. ReparentNotify event processing.  Finally, if the specified
  12006. window was originally mapped, this function automatically
  12007. performs a XMapWindow request on it.
  12008.  
  12009. The X server performs normal exposure processing on formerly
  12010. obscured windows.  The X server might not generate exposure
  12011. events for regions from the initial XUnmapWindow request
  12012. that are immediately obscured by the final XMapWindow
  12013. request.  A BadMatch error is generated:
  12014.  
  12015. o    If the new parent window is not on the same screen as
  12016.      the old parent window
  12017.  
  12018. o    If the new parent window is the specified window or an
  12019.      inferior of the specified window
  12020.  
  12021. o    If the specified window has a ParentRelative background
  12022.      and if the new parent window is not the same depth as
  12023.      the specified window.
  12024.  
  12025. The other error that can be generated by XReparentWindow is
  12026. BadWindow.
  12027.  
  12028. 7.2.  Controlling the Lifetime of a Window
  12029.  
  12030. The save-set of a client is a list of other client's windows
  12031. which, if they are inferiors of one of the client's windows
  12032. at connection close, should not be destroyed and should be
  12033. remapped if they are unmapped.  To allow an application's
  12034.  
  12035.  
  12036.  
  12037.                      December 18, 1987
  12038.  
  12039.  
  12040.  
  12041.  
  12042.  
  12043.                           - 175 -
  12044.  
  12045.  
  12046. window to survive when a window manager that has reparented
  12047. a window fails, Xlib provides the save-set functions with
  12048. which you can change a client's save-set, add a subwindow to
  12049. a client's save-set, or remove a subwindow from a client's
  12050. save-set.
  12051.  
  12052. The functions described in this section are used to control
  12053. the longevity of subwindows that are normally destroyed when
  12054. the parent is destroyed.  For example, a window manager that
  12055. wants to add decoration to a window by adding a frame might
  12056. reparent an application's window. When the frame is des-
  12057. troyed, the application's window should not be destroyed,
  12058. but returned to its previous place in the window hierarchy.
  12059.  
  12060. Windows are removed automatically from the save-set by the X
  12061. server when they are destroyed.  For each window in the
  12062. client's save-set, if the window is an inferior of a window
  12063. created by the client, the save-set window is reparented to
  12064. the closest ancestor such that the save-set window is not an
  12065. inferior of a window created by the client. If the save-set
  12066. window is unmapped, a MapWindow request is performed on it.
  12067. After save-set processing, all windows created by the client
  12068. are destroyed. For each nonwindow resource created by the
  12069. client, the appropriate Free request is performed. All
  12070. colors and color map entries allocated by the client are
  12071. freed.
  12072.  
  12073.  
  12074. Use XChangeSaveSet to add or remove a window from the
  12075. client's save-set. The definition for this function is:
  12076.  
  12077. XChangeSaveSet(display, w, change_mode)
  12078.       Display *display;
  12079.       Window w;
  12080.       int change_mode;
  12081.  
  12082.  
  12083. display   Specifies the connection to the X server.
  12084.  
  12085. w_add     Specifies the window ID of the window whose chil-
  12086.           dren you want to add to the client's save-set.
  12087.  
  12088. change_modeSpecifies the mode.  You can pass one of the con-
  12089.           stants SetModeInsert or SetModeDelete.  If SetMo-
  12090.           deInsert, XChangeSaveSet adds the window to this
  12091.           client's save-set. If SetModeDelete,
  12092.           XChangeSaveSet deletes the window from this
  12093.           client's save-set.
  12094.  
  12095. Depending on the constant you passed to the change_mode
  12096. argument, the XChangeSaveSet function either adds or removes
  12097. a subwindow from the client's save-set. The specified window
  12098. must have been created by some other client. Otherwise, a
  12099. BadMatch error is generated.  See Section 2.6 for
  12100.  
  12101.  
  12102.  
  12103.                      December 18, 1987
  12104.  
  12105.  
  12106.  
  12107.  
  12108.  
  12109.                           - 176 -
  12110.  
  12111.  
  12112. information on what happens to the save-set during connec-
  12113. tion close.  The X server automatically removes windows from
  12114. the save-set when they are destroyed.
  12115.  
  12116. The other event errors that can be generated by
  12117. XChangeSaveSet are BadWindow, BadMatch, and BadValue.
  12118.  
  12119.  
  12120. Use XAddToSaveSet to add a window to the client's save-set.
  12121. The definition for this function is:
  12122.  
  12123. XAddToSaveSet(display, w_add)
  12124.       Display *display;
  12125.       Window w_add;
  12126.  
  12127.  
  12128. display   Specifies the connection to the X server.
  12129.  
  12130. w_add     Specifies the window ID of the window whose chil-
  12131.           dren you want to add to the client's save-set.
  12132.  
  12133. The XAddToSaveSet function adds the children of the speci-
  12134. fied window to the client's save-set.  The specified window
  12135. must have been created by some other client. Otherwise, a
  12136. BadMatch error is generated.  See Section 2.6 for informa-
  12137. tion on what happens to the save-set during connection
  12138. close.  The X server automatically removes windows from the
  12139. save-set when they are destroyed.
  12140.  
  12141. The other event errors that can be generated by XAddTo-
  12142. SaveSet are BadWindow and BadMatch.
  12143.  
  12144.  
  12145. Use XRemoveFromSaveSet to remove a window from the client's
  12146. save-set.  The definition for this function is:
  12147.  
  12148. XRemoveFromSaveSet(display, w_remove)
  12149.       Display *display;
  12150.       Window w_remove;
  12151.  
  12152.  
  12153. display   Specifies the connection to the X server.
  12154.  
  12155. w_remove  Specifies the window ID of the window whose chil-
  12156.           dren you want to remove frem the client's save-
  12157.           set.
  12158.  
  12159. The XRemoveFromSaveSet function removes the children of the
  12160. specified window from the client's save-set.  The specified
  12161. window must have been created by some other client. Other-
  12162. wise, a BadMatch error is generated.  See Section 2.6 for
  12163. information on what happens to the save-set during connec-
  12164. tion close.  The X server automatically removes windows from
  12165. the save-set when they are destroyed.
  12166.  
  12167.  
  12168.  
  12169.                      December 18, 1987
  12170.  
  12171.  
  12172.  
  12173.  
  12174.  
  12175.                           - 177 -
  12176.  
  12177.  
  12178. The other event errors that can be generated by XRemoveFrom-
  12179. SaveSet are BadWindow and BadMatch.
  12180.  
  12181. 7.3.  Manipulating Color Maps
  12182.  
  12183. Xlib provides functions with which you can install a color
  12184. map, uninstall a color map, and obtain a list of installed
  12185. color maps.
  12186.  
  12187. Window manager applications usually install and uninstall
  12188. color maps, and, thus, these tasks should not be performed
  12189. by normal client applications.  The X server always main-
  12190. tains a subset of the installed color maps in an ordered
  12191. list called the ``required list.''  The length of the
  12192. required list is at most the minimum installed  maps speci-
  12193. fied for the screen when the connection is opened to the
  12194. server.  Initially, only the default color map for a screen
  12195. is installed, but it is not in the required list.  The X
  12196. server maintains the required list as follows:
  12197.  
  12198. o    If you pass a color map resource ID to the cmap argu-
  12199.      ment, XInstallColormap adds the color map to the top of
  12200.      the list and truncates a color map at the bottom of the
  12201.      list, if necessary, so as not to exceed the maximum
  12202.      length of the list.
  12203.  
  12204. o    If you pass a color map resource ID to the cmap argu-
  12205.      ment and that color map is in the required list, XUnin-
  12206.      stallColormap removes the color map from the required
  12207.      list.  A colormap is not added to the required list
  12208.      when it is installed implicitly by the server, and the
  12209.      X server cannot implicitly uninstall a colormap that is
  12210.      in the required list.
  12211.  
  12212.  
  12213. Use XInstallColormap to install a color map. The definition
  12214. for this function is:
  12215.  
  12216. XInstallColormap(display, cmap)
  12217.       Display *display;
  12218.       Colormap cmap;
  12219.  
  12220.  
  12221. display   Specifies the connection to the X server.
  12222.  
  12223. cmap      Specifies the color map ID.
  12224.  
  12225. The XInstallColormap function installs the specified color
  12226. map for its associated screen.  All windows associated with
  12227. this color map immediately display with true colors.  You
  12228. associated the windows with this color map when you created
  12229. them by calling the functions XCreateWindow or XCreateSim-
  12230. pleWindow.  See Chapter 3 for a discussion of how to associ-
  12231. ate a window with a color map using these functions.
  12232.  
  12233.  
  12234.  
  12235.                      December 18, 1987
  12236.  
  12237.  
  12238.  
  12239.  
  12240.  
  12241.                           - 178 -
  12242.  
  12243.  
  12244. The X server obtains the color map from a required list,
  12245. which is an ordered list containing a subset of the
  12246. installed color maps.  The X server might implicitly install
  12247. or uninstall additional color maps.  Which other color maps
  12248. get installed or uninstalled is sever-dependent, except that
  12249. the required list must remain installed.  If the specified
  12250. color map is not already an installed color map, the X
  12251. server generates a ColormapNotify event on every window hav-
  12252. ing the cmap as the color map resource ID.  In addition, for
  12253. every other color map that is installed or uninstalled as a
  12254. result of a call to this function, the X server generates a
  12255. ColormapNotify event on every window having that cmap as the
  12256. color map resource ID.
  12257.  
  12258. The error that can be generated by XInstallColormap is Bad-
  12259. Color.
  12260.  
  12261.  
  12262. Use XUninstallColormap to uninstall a color map. The defini-
  12263. tion for this function is:
  12264.  
  12265. XUninstallColormap(display, cmap)
  12266.       Display *display;
  12267.       Colormap cmap;
  12268.  
  12269.  
  12270. display   Specifies the connection to the X server.
  12271.  
  12272. cmap      Specifies the color map ID.
  12273.  
  12274. The XUninstallColormap function removes the specified color
  12275. map from the required list for its screen.  As a result, the
  12276. specified cmap might be uninstalled, and the X server might
  12277. implicitly install or uninstall additional color maps.
  12278. Which color maps get installed or uninstalled is sever-
  12279. dependent, except that the required list must remain
  12280. installed.
  12281.  
  12282. If the specified color map becomes uninstalled, the X server
  12283. generates a ColormapNotify event on every window having the
  12284. cmap as the color map resource ID.  In addition, for every
  12285. other color map that is uninstalled as a result of a call to
  12286. this function, the X server generates a ColormapNotify event
  12287. on every window having that cmap as the color map resource
  12288. ID.
  12289.  
  12290. The error that can be generated by XUninstallColormap is
  12291. BadColor.
  12292.  
  12293.  
  12294. Use XListInstalledColormaps to obtain a list of the
  12295. currently installed color maps. The definition for this
  12296. function is:
  12297.  
  12298.  
  12299.  
  12300.  
  12301.                      December 18, 1987
  12302.  
  12303.  
  12304.  
  12305.  
  12306.  
  12307.                           - 179 -
  12308.  
  12309.  
  12310. Colormap *XListInstalledColormaps(display, w, num_return)
  12311.       Display *display;
  12312.       Window w;
  12313.       int *num_return;
  12314.  
  12315.  
  12316. display   Specifies the connection to the X server.
  12317.  
  12318. w         Specifies the window ID.  This is the window whose
  12319.           screen you want to obtain the list of currently
  12320.           installed color maps.
  12321.  
  12322. num_returnReturns the list of currently installed color
  12323.           maps.
  12324.  
  12325. The XListInstalledColormaps function returns a list of the
  12326. currently installed color maps for the screen of the speci-
  12327. fied window.  The order in which the color maps appear in
  12328. the list is not significant, and there is no explicit indi-
  12329. cation of the required list.  You should free the allocated
  12330. list by using XFree, when it no longer is needed.  (See Sec-
  12331. tion 2.4 for further information.)
  12332.  
  12333. The error that can be generated by XListInstalledColormaps
  12334. is BadWindow.
  12335.  
  12336. 7.4.  Manipulating the Pointer
  12337.  
  12338. Xlib provides functions with which you can control input
  12339. from the pointer, which usually is a mouse.
  12340.  
  12341.                             Note
  12342.  
  12343.      Window managers most often use these facilities to
  12344.      implement certain styles of user interfaces.  Some
  12345.      applications may use these facilities for special
  12346.      purposes.  However, most applications will not use
  12347.      these functions.
  12348.  
  12349.  
  12350. Usually, the X server delivers keyboard and mouse events as
  12351. soon as they occur to the appropriate client depending upon
  12352. the window and input focus.  The X server provides suffi-
  12353. cient control over event delivery to allow window managers
  12354. to support mouse ahead and various other styles of user
  12355. interface.  Many of these depend upon synchronous delivery
  12356. of events.  The delivery of  pointer and keyboard events can
  12357. be controlled independently.
  12358.  
  12359. When mouse buttons or keyboard keys are grabbed, events will
  12360. be sent to the grabbing client rather than the normal client
  12361. who would have received the event.  If the keyboard or
  12362. pointer is in asynchronous mode, further mouse and keyboard
  12363. events will continue to be processed.  If the keyboard or
  12364.  
  12365.  
  12366.  
  12367.                      December 18, 1987
  12368.  
  12369.  
  12370.  
  12371.  
  12372.  
  12373.                           - 180 -
  12374.  
  12375.  
  12376. pointer is in synchronous mode, no further events will be
  12377. processed until the grabbing client allows them.  (See XAl-
  12378. lowEvents.)  The keyboard or pointer is considered frozen
  12379. during this interval.  The triggering event can also be
  12380. replayed.
  12381.  
  12382. There are two kinds of grabs:  active and passive.  An
  12383. active grab occurs when a single client grabs the keyboard
  12384. and/or pointer explicitly.  (See XGrabPointer and XGrabKey-
  12385. board.)  Clients can also grab a particular keyboard key or
  12386. pointer button in a window.  The grab activates when the key
  12387. or button is actually pressed, and is called a ``passive
  12388. grab''.  Passive grabs can be very convenient for implement-
  12389. ing reliable pop-up menus.  For example, you can arrange to
  12390. guarantee that the pop-up will be mapped before the up
  12391. pointer button event occurs by grabbing a button requesting
  12392. synchronous behavior.  The down event will trigger the grab
  12393. and freeze further processing of pointer events until you
  12394. have the chance to map the pop up window.  You can then
  12395. allow further event processing.  The up event will then be
  12396. correctly processed relative to the pop-up window.
  12397.  
  12398. For many operations, there are functions which take a time
  12399. argument.  The X server includes a time stamp in various
  12400. events.  One special time called CurrentTime represents the
  12401. current server time.  The X server maintains the time when
  12402. the input focus was last changed and the time of the server
  12403. itself when the client last performed an active grab (dis-
  12404. cussed below), when the keyboard was last grabbed, when the
  12405. pointer was last grabbed, or when a selection was last
  12406. changed.  Your application may be slow reacting to an event.
  12407. You often need some way to specify that your request not
  12408. occur if some other application has in the meanwhile taken
  12409. control of the keyboard, pointer, or selection.  By provid-
  12410. ing the timestamp from the event in the request, you can
  12411. arrange that the operation not take effect if someone else
  12412. has in the meanwhile performed an operation.
  12413.  
  12414.  
  12415. Use XGrabPointer to grab the pointer. The definition for
  12416. this function is:
  12417.  
  12418. int XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode,
  12419.                keyboard_mode, confine_to, cursor, time)
  12420.       Display *display;
  12421.       Window grab_window;
  12422.       Bool owner_events;
  12423.       unsigned int event_mask;
  12424.       int pointer_mode, keyboard_mode;
  12425.       Window confine_to;
  12426.       Cursor cursor;
  12427.       Time time;
  12428.  
  12429.  
  12430.  
  12431.  
  12432.  
  12433.                      December 18, 1987
  12434.  
  12435.  
  12436.  
  12437.  
  12438.  
  12439.                           - 181 -
  12440.  
  12441.  
  12442. display   Specifies the connection to the X server.
  12443.  
  12444. grab_windowSpecifies the window ID of the window relative to
  12445.           which events are reported while it is grabbed.
  12446.  
  12447. owner_eventsSpecifies if the pointer events are to be
  12448.           reported normally (pass True) or with respect to
  12449.           the grab window if selected by the event mask
  12450.           (pass False).
  12451.  
  12452. event_maskSpecifies which pointer events are reported to the
  12453.           client.  They can be the bitwise inclusive OR of
  12454.           these pointer event mask bits:  ButtonPressMask,
  12455.           ButtonReleaseMask, EnterWindowMask, LeaveWin-
  12456.           dowMask, PointerMotionMask, PointerMotionHintMask,
  12457.           Button1MotionMask, Button2MotionMask,
  12458.           Button3MotionMask, Button4MotionMask,
  12459.           Button5MotionMask, ButtonMotionMask, KeyMapSta-
  12460.           teMask.
  12461.  
  12462. pointer_modeControls further processing of pointer events.
  12463.           You can pass one of these constants:  GrabModeSync
  12464.           or GrabModeAsync.
  12465.  
  12466. keyboard_modeControls further processing of keyboard events.
  12467.           You can pass one of these constants:  GrabModeSync
  12468.           or GrabModeAsync.
  12469.  
  12470. confine_toSpecifies the window to confine the pointer in or
  12471.           None if it is not to be confined.
  12472.  
  12473. cursor    Specifies the cursor that is to be displayed dur-
  12474.           ing the grab.
  12475.  
  12476. time      Specifies the time.  You can pass either a times-
  12477.           tamp, expressed in milliseconds, or the constant
  12478.           CurrentTime.
  12479.  
  12480. The XGrabPointer function actively grabs control of the
  12481. pointer and returns GrabSuccess if the grab was successful.
  12482. Further pointer events are only reported to the grabbing
  12483. client.  This function overrides any active pointer grab by
  12484. this client.  If owner_events is False, all generated
  12485. pointer events are reported with respect to grab_window and
  12486. are only reported if selected by event_mask.  If
  12487. owner_events is True, and if a generated pointer event would
  12488. normally be reported to this client, it is reported nor-
  12489. mally. Otherwise, the event is reported with respect to the
  12490. grab_window and is only reported if selected by event_mask.
  12491. For either value of owner_events, unreported events are dis-
  12492. carded.
  12493.  
  12494. Pointer_mode controls further processing of pointer events,
  12495. and keyboard_mode controls further processing of main
  12496.  
  12497.  
  12498.  
  12499.                      December 18, 1987
  12500.  
  12501.  
  12502.  
  12503.  
  12504.  
  12505.                           - 182 -
  12506.  
  12507.  
  12508. keyboard events. If the pointer_mode is GrabModeAsync,
  12509. pointer event processing continues normally.  If the pointer
  12510. is currently frozen by this client, the processing of events
  12511. for the pointer is resumed.  If the pointer_mode is GrabMo-
  12512. deSync, the the pointer, as seen by client applications,
  12513. appears to freeze, and no further pointer events are gen-
  12514. erated by the X server until the grabbing client calls the
  12515. XAllowEvents function.  Actual pointer changes are not lost
  12516. while the pointer is frozen; they are simply queued for
  12517. later processing.
  12518.  
  12519. If the keyboard_mode is GrabModeAsync, keyboard event pro-
  12520. cessing is unaffected by activation of the grab.  If the
  12521. keyboard_mode is GrabModeSync, the the keyboard, as seen by
  12522. client applications, appears to freeze, and no further key-
  12523. board events are generated by the X server until the grab-
  12524. bing client calls the XAllowEvents function.  Actual key-
  12525. board changes are not lost while the pointer is frozen; they
  12526. are simply queued for later processing.
  12527.  
  12528. If a cursor is specified, it is displayed regardless of what
  12529. window the pointer is in. If no cursor is specified, the
  12530. normal cursor for that window is displayed when the pointer
  12531. is in grab_window or one of its subwindows; otherwise, the
  12532. cursor for grab_window is displayed.
  12533.  
  12534. If a confine_to window is specified, the pointer will be
  12535. restricted to stay contained in that window.  The confine_to
  12536. window need have no relationship to the grab_window.  If the
  12537. pointer is not initially in the confine_to window, it is
  12538. warped automatically to the closest edge just before the
  12539. grab activates and enter/leave events are generated nor-
  12540. mally. If the confine_to window is subsequently reconfig-
  12541. ured, the pointer will be warped automatically as necessary
  12542. to keep it contained in the window.
  12543.  
  12544. The time argument allows you to avoid certain circumstances
  12545. that come up if applications take a long while to respond or
  12546. if there are long network delays.  Consider a situation
  12547. where you have two applications, both of which normally grab
  12548. the pointer when clicked on.  If both applications specify
  12549. the timestamp from the event, the second application may
  12550. successfully grab the pointer, while the first gets an indi-
  12551. cation the other application grabbed the pointer before its
  12552. request was processed.
  12553.  
  12554. XGrabPointer generates EnterNotify and LeaveNotify events.
  12555.  
  12556. The XGrabPointer function fails and returns:
  12557.  
  12558. GrabNotViewable
  12559.                   If grab_window or confine_to window is not
  12560.                   viewable.
  12561.  
  12562.  
  12563.  
  12564.  
  12565.  
  12566.                      December 18, 1987
  12567.  
  12568.  
  12569.  
  12570.  
  12571.  
  12572.                           - 183 -
  12573.  
  12574.  
  12575.  
  12576.  
  12577.  
  12578.  
  12579.  
  12580.  
  12581.  
  12582.  
  12583.  
  12584.  
  12585.  
  12586.  
  12587.  
  12588.  
  12589.  
  12590.  
  12591.  
  12592.  
  12593.  
  12594.  
  12595.  
  12596.  
  12597.  
  12598.  
  12599.  
  12600.  
  12601.  
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.  
  12611.  
  12612.  
  12613.  
  12614.  
  12615.  
  12616.  
  12617.  
  12618.  
  12619.  
  12620.  
  12621.  
  12622.  
  12623.  
  12624.  
  12625.  
  12626.  
  12627.  
  12628.  
  12629.  
  12630.  
  12631.  
  12632.                      December 18, 1987
  12633.  
  12634.  
  12635.  
  12636.  
  12637.  
  12638.                           - 184 -
  12639.  
  12640.  
  12641. AlreadyGrabbed
  12642.                   If the pointer is actively grabbed by some
  12643.                   other client.
  12644.  
  12645.  
  12646. GrabFrozen
  12647.                   If the pointer is frozen by an active grab
  12648.                   of another client.
  12649.  
  12650.  
  12651. GrabInvalidTime
  12652.                   If the specified time is earlier than the
  12653.                   last-pointer-grab time or later than the
  12654.                   current X server time.  Otherwise, the
  12655.                   last-pointer-grab time is set to the
  12656.                   specified time and the constant Current-
  12657.                   Time is replaced by the current X server
  12658.                   time.
  12659.  
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665.  
  12666.  
  12667.  
  12668. The errors that can be generated by XGrabPointer are BadWin-
  12669. dow, BadCursor, and BadValue.
  12670.  
  12671.  
  12672. Use XGrabButton to grab a mouse button. The definition for
  12673. this function is:
  12674.  
  12675. XGrabButton(display, button_grab, modifiers, grab_window, owner_events, event_mask,
  12676.                 pointer_mode, keyboard_mode, confine_to, cursor)
  12677.       Display *display;
  12678.       unsigned int button_grab;
  12679.       unsigned int modifiers;
  12680.       Window grab_window;
  12681.       Bool owner_events;
  12682.       unsigned int event_mask;
  12683.       int pointer_mode, keyboard_mode;
  12684.       Window confine_to;
  12685.       Cursor cursor;
  12686.  
  12687.  
  12688. display   Specifies the connection to the X server.
  12689.  
  12690. button_grabSpecifies the pointer button that is to be
  12691.           grabbed when the specified modifier keys are down.
  12692.           You can pass the constant AnyButton, which is
  12693.           equivalent to issuing the grab request for all
  12694.           possible buttons.
  12695.  
  12696. modifiers Specifies the set of keymasks.  This mask is the
  12697.           bitwise inclusive OR of these keymask bits:
  12698.           ShiftMask, LockMask, ControlMask, Mod1Mask,
  12699.           Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.  You can
  12700.           also pass the constant AnyModifier, which is
  12701.           equivalent to issuing the grab request for all
  12702.           possible modifier combinations (including the com-
  12703.           bination of no modifiers).
  12704.  
  12705. grab_windowSpecifies the window ID of the window you want to
  12706.           grab.
  12707.  
  12708.  
  12709.  
  12710.  
  12711.                      December 18, 1987
  12712.  
  12713.  
  12714.  
  12715.  
  12716.  
  12717.                           - 185 -
  12718.  
  12719.  
  12720. owner_eventsSpecifies if the pointer events are to be
  12721.           reported normally (pass True) or with respect to
  12722.           the grab window if selected by the event mask
  12723.           (pass False).
  12724.  
  12725. event_maskSpecifies which pointer events are reported to the
  12726.           client.  They can be the bitwise inclusive OR of
  12727.           these pointer event mask bits:  ButtonPressMask,
  12728.           ButtonReleaseMask, EnterWindowMask, LeaveWin-
  12729.           dowMask, PointerMotionMask, PointerMotionHintMask,
  12730.           Button1MotionMask, Button2MotionMask,
  12731.           Button3MotionMask, Button4MotionMask,
  12732.           Button5MotionMask, ButtonMotionMask, KeyMapSta-
  12733.           teMask.
  12734.  
  12735. pointer_modeControls further processing of pointer events.
  12736.           You can pass one of these constants:  GrabModeSync
  12737.           or GrabModeAsync.
  12738.  
  12739. keyboard_modeControls further processing of keyboard events.
  12740.           You can pass one of these constants:  GrabModeSync
  12741.           or GrabModeAsync.
  12742.  
  12743. confine_toSpecifies the window to confine the pointer in or
  12744.           None if it is not to be confined.
  12745.  
  12746. cursor    Specifies the cursor that is to be displayed dur-
  12747.           ing the grab.
  12748.  
  12749. The XGrabButton function establishes a passive grab.  Conse-
  12750. quently, in the future:
  12751.  
  12752. o    IF the specified button is pressed when the specified
  12753.      modifier keys are down (and no other buttons or modif-
  12754.      ier keys are down)
  12755.  
  12756. o    AND if grab_window contains the pointer
  12757.  
  12758. o    AND if the confine_to window (if any) is viewable
  12759.  
  12760. o    AND if these constraints are not satisfied for any
  12761.      ancestor
  12762.  
  12763. o    THEN the pointer is actively grabbed, as for XGrab-
  12764.      Pointer, the last-pointer-grab time is set to the time
  12765.      at which the button was pressed (as transmitted in the
  12766.      ButtonPress event), and the ButtonPress events is
  12767.      reported.
  12768.  
  12769. The interpretation of the remaining arguments is as for
  12770. XGrabPointer.  The active grab is terminated automatically
  12771. when all buttons are released (independent of the state of
  12772. the modifier keys).
  12773.  
  12774.  
  12775.  
  12776.  
  12777.                      December 18, 1987
  12778.  
  12779.  
  12780.  
  12781.  
  12782.  
  12783.                           - 186 -
  12784.  
  12785.  
  12786. A modifiers of AnyModifier is equivalent to issuing the grab
  12787. request for all possible modifier combinations (including
  12788. the combination of no modifiers). It is not required that
  12789. all modifiers specified have currently assigned keycodes.  A
  12790. button of AnyButton is equivalent to issuing the request for
  12791. all possible buttons.  Otherwise, it is not required that
  12792. the specified button currently be assigned to a physical
  12793. button.
  12794.  
  12795. The request fails and the X server generates a BadAccess
  12796. error if some other client has already issued a XGrabButton
  12797. with the same button/key combination on the same window.
  12798. When using AnyModifier or AnyButton, the request fails com-
  12799. pletely generating an BadAccess error (no grabs are esta-
  12800. blished) if there is a conflicting grab for any combination.
  12801. The request has no effect on an active grab.
  12802.  
  12803. The other event errors that can be generated by XGrabButton
  12804. are BadWindow, BadCursor, BadAccess, and BadValue.
  12805.  
  12806.  
  12807. Use XUngrabButton to ungrab a mouse button. The definition
  12808. for this function is:
  12809.  
  12810. XUngrabButton(display, button_ungrab, modifiers, ungrab_window)
  12811.       Display *display;
  12812.       unsigned int button_ungrab;
  12813.       unsigned int modifiers;
  12814.       Window ungrab_window;
  12815.  
  12816.  
  12817. display   Specifies the connection to the X server.
  12818.  
  12819. button_ungrabSpecifies the pointer button that is to be
  12820.           released in combination with the modifier keys.
  12821.           You can pass the constant AnyButton, which is
  12822.           equivalent to issuing the ungrab request for all
  12823.           possible buttons.
  12824.  
  12825. modifiers Specifies the set of keymasks.  This mask is the
  12826.           bitwise inclusive OR of these keymask bits:
  12827.           ShiftMask, LockMask, ControlMask, Mod1Mask,
  12828.           Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.  You can
  12829.           also pass the constant AnyModifier, which is
  12830.           equivalent to issuing the ungrab request for all
  12831.           possible modifier combinations (including the com-
  12832.           bination of no modifiers).
  12833.  
  12834. ungrab_windowSpecifies the window ID of the window you want
  12835.           to ungrab.
  12836.  
  12837. The XUngrabButton function releases the passive button/key
  12838. combination on the specified window if it was grabbed by
  12839. this client.  A modifiers of AnyModifier is equivalent to
  12840.  
  12841.  
  12842.  
  12843.                      December 18, 1987
  12844.  
  12845.  
  12846.  
  12847.  
  12848.  
  12849.                           - 187 -
  12850.  
  12851.  
  12852. issuing the ungrab request for all possible modifier combi-
  12853. nations, including the combination of no modifiers.  A but-
  12854. ton of AnyButton is equivalent to issuing the request for
  12855. all possible buttons.  This function has no effect on an
  12856. active grab.
  12857.  
  12858. The error that can be generated by XUngrabButton is BadWin-
  12859. dow.
  12860.  
  12861.  
  12862. Use XUngrabPointer to ungrab the pointer. The definition for
  12863. this function is:
  12864.  
  12865. XUngrabPointer(display, time)
  12866.       Display *display;
  12867.       Time time;
  12868.  
  12869.  
  12870. display   Specifies the connection to the X server.
  12871.  
  12872. time      Specifies the time.  You can pass either a times-
  12873.           tamp, expressed in milliseconds, or the constant
  12874.           CurrentTime.
  12875.  
  12876. The XUngrabPointer function releases the pointer and any
  12877. queued events, if this client has actively grabbed the
  12878. pointer from XGrabPointer, XGrabButton, or from a normal
  12879. button press.  The function does not release the pointer if
  12880. the specified time is earlier than the last-pointer-grab
  12881. time or is later than the current X server time.  It also
  12882. generates EnterNotify and LeaveNotify events.  The X server
  12883. performs an XUngrabPointer automatically if the event window
  12884. or confine-to window for an active pointer grab becomes not
  12885. viewable.
  12886.  
  12887.  
  12888. Use XChangeActivePointerGrab to change the active pointer.
  12889. The definition for this function is:
  12890.  
  12891. XChangeActivePointerGrab(display, event_mask, cursor, time)
  12892.       Display *display;
  12893.       unsigned int event_mask;
  12894.       Cursor cursor;
  12895.       Time time;
  12896.  
  12897.  
  12898. display   Specifies the connection to the X server.
  12899.  
  12900. event_maskSpecifies which pointer events are reported to the
  12901.           client.  They can be the bitwise inclusive OR of
  12902.           these pointer event mask bits:  ButtonPressMask,
  12903.           ButtonReleaseMask, EnterWindowMask, LeaveWin-
  12904.           dowMask, PointerMotionMask, PointerMotionHintMask,
  12905.           Button1MotionMask, Button2MotionMask,
  12906.  
  12907.  
  12908.  
  12909.                      December 18, 1987
  12910.  
  12911.  
  12912.  
  12913.  
  12914.  
  12915.                           - 188 -
  12916.  
  12917.  
  12918.           Button3MotionMask, Button4MotionMask,
  12919.           Button5MotionMask, ButtonMotionMask, KeyMapSta-
  12920.           teMask.
  12921.  
  12922. cursor    Specifies the cursor. This is the cursor that is
  12923.           displayed.  A possible value you can pass is None.
  12924.  
  12925. time      Specifies the time.  You can pass either a times-
  12926.           tamp, expressed in milliseconds, or the constant
  12927.           CurrentTime.
  12928.  
  12929. The XChangeActivePointerGrab function changes the specified
  12930. dynamic parameters if the pointer is actively grabbed by the
  12931. client and if the specified time is no earlier than the
  12932. last-pointer-grab time and no later than the current X
  12933. server time.  This function has no effect on the passive
  12934. parameters of a XGrabButton.  The event-mask is always aug-
  12935. mented to include ButtonPress mask and ButtonRelease mask.
  12936. The interpretation of event_mask and cursor is the same as
  12937. described in XGrabPointer.
  12938.  
  12939. The error that can be generated by XChangeActivePointerGrab
  12940. is BadCursor.
  12941.  
  12942. 7.5.  Manipulating the Keyboard
  12943.  
  12944. Xlib provides functions with which you can grab or ungrab
  12945. the keyboard as well as allow events.
  12946.  
  12947.  
  12948. Use XGrabKeyboard to grab the keyboard. The definition for
  12949. this function is:
  12950.  
  12951. int XGrabKeyboard(display, grab_window, owner_events, pointer_mode, keyboard_mode, time)
  12952.       Display *display;
  12953.       Window grab_window;
  12954.       Bool owner_events;
  12955.       int pointer_mode, keyboard_mode;
  12956.       Time time;
  12957.  
  12958.  
  12959. display   Specifies the connection to the X server.
  12960.  
  12961. grab_windowSpecifies the window ID of the window associated
  12962.           with the keyboard you want to grab.
  12963.  
  12964. owner_eventsSpecifies a boolean value of either True or
  12965.           False.
  12966.  
  12967. pointer_modeControls further processing of pointer events.
  12968.           You can pass one of these constants:  GrabModeSync
  12969.           or GrabModeAsync.
  12970.  
  12971.  
  12972.  
  12973.  
  12974.  
  12975.                      December 18, 1987
  12976.  
  12977.  
  12978.  
  12979.  
  12980.  
  12981.                           - 189 -
  12982.  
  12983.  
  12984. keyboard_modeControls further processing of keyboard events.
  12985.           You can pass one of these constants:  GrabModeSync
  12986.           or GrabModeAsync.
  12987.  
  12988. time      Specifies the time.  You can pass either a times-
  12989.           tamp, expressed in milliseconds, or the constant
  12990.           CurrentTime.
  12991.  
  12992. The XGrabKeyboard function actively grabs control of the
  12993. main keyboard and generates FocusIn and FocusOut events.
  12994. Further key events are reported only to the grabbing client.
  12995. This function overrides any active keyboard grab by this
  12996. client.  If owner_events is False, all generated key events
  12997. are reported with respect to grab_window. If owner_events is
  12998. True, then if a generated key event would normally be
  12999. reported to this client, it is reported normally; otherwise
  13000. the event is reported with respect to the grab_window. Both
  13001. KeyPress and KeyRelease events are always reported, indepen-
  13002. dent of any event selection made by the client.
  13003.  
  13004. The pointer_mode argument controls the further processing of
  13005. pointer events, and the keyboard_mode argument controls the
  13006. further processing of the keyboard events.
  13007.  
  13008. o    If the keyboard_mode argument is GrabModeAsync, key-
  13009.      board event processing continues normally; if the key-
  13010.      board is currently frozen by this client, then process-
  13011.      ing of keyboard events is resumed.  If the
  13012.      keyboard_mode  argument is GrabModeSync, the keyboard
  13013.      (as seen by client applications) appears to freeze, and
  13014.      no further keyboard events are generated by the server
  13015.      until the grabbing client issues a releasing XAl-
  13016.      lowEvents call.  Actual keyboard changes are not lost
  13017.      while the keyboard is frozen; they are simply queued
  13018.      for later processing.
  13019.  
  13020. o    If pointer_mode is GrabModeAsync, pointer event pro-
  13021.      cessing is unaffected by activation of the grab. If
  13022.      pointer_mode is GrabModeSync, the pointer (as seen by
  13023.      client applications) appears to freeze, and no further
  13024.      pointer events are generated by the server until the
  13025.      grabbing client issues a releasing XAllowEvents call.
  13026.      Actual pointer changes are not lost while the pointer
  13027.      is frozen; they are simply queued for later processing.
  13028.  
  13029. XGrabKeyboard fails and returns:
  13030.  
  13031. AlreadyGrabbed
  13032.                   If the keyboard is actively grabbed by
  13033.                   some other client.
  13034.  
  13035.  
  13036. GrabNotViewable
  13037.                   If grab_window is not viewable.
  13038.  
  13039. GrabInvalidTime
  13040.  
  13041.  
  13042.  
  13043.  
  13044.  
  13045.                      December 18, 1987
  13046.  
  13047.  
  13048.  
  13049.  
  13050.  
  13051.                           - 190 -
  13052.  
  13053.  
  13054.                   If the specified time is earlier than the
  13055.                   last-keyboard-grab time or later than the
  13056.                   current X server time.  Otherwise, the
  13057.                   last-keyboard-grab time is set to the
  13058.                   specified time and CurrentTime is replaced
  13059.                   by the current X server time.
  13060.  
  13061.  
  13062.  
  13063.  
  13064.  
  13065.  
  13066.  
  13067.  
  13068.  
  13069.  
  13070.  
  13071.  
  13072.  
  13073.  
  13074.  
  13075.  
  13076.  
  13077.  
  13078.  
  13079.  
  13080.  
  13081.  
  13082.  
  13083.  
  13084.  
  13085.  
  13086.  
  13087.  
  13088.  
  13089.  
  13090.  
  13091.  
  13092.  
  13093.  
  13094.  
  13095.  
  13096.  
  13097.  
  13098.  
  13099.  
  13100.  
  13101.  
  13102.  
  13103.  
  13104.  
  13105.  
  13106.  
  13107.  
  13108.  
  13109.  
  13110.  
  13111.                      December 18, 1987
  13112.  
  13113.  
  13114.  
  13115.  
  13116.  
  13117.                           - 191 -
  13118.  
  13119.  
  13120. GrabFrozen
  13121.                   If the keyboard is frozen by an active
  13122.                   grab of another client.
  13123.  
  13124.  
  13125.  
  13126.  
  13127. The errors that can be generated by XGrabKeyboard are
  13128. BadWindow and BadValue.
  13129.  
  13130.  
  13131. Use XUngrabKeyboard to ungrab the keyboard. The definition
  13132. for this function is:
  13133.  
  13134. XUngrabKeyboard(display, time)
  13135.       Display *display;
  13136.       Time time;
  13137.  
  13138.  
  13139. display   Specifies the connection to the X server.
  13140.  
  13141. time      Specifies the time.  You can pass either a times-
  13142.           tamp, expressed in milliseconds, or the constant
  13143.           CurrentTime.
  13144.  
  13145. The XUngrabKeyboard function releases the keyboard and any
  13146. queued events if this client has it actively grabbed from
  13147. either XGrabKeyboard or XGrabKey.  The function does not
  13148. release the keyboard and any queued events if the specified
  13149. time is earlier than the last-keyboard-grab time or is later
  13150. than the current X server time.  It also generates FocusIn
  13151. and FocusOut events.  The X server automatically performs an
  13152. XUngrabKeyboard if the event window for an active keyboard
  13153. grab becomes not viewable.
  13154.  
  13155.  
  13156. Use XGrabKey to passively grab a single key of the keyboard
  13157. key. The definition for this function is:
  13158.  
  13159. XGrabKey(display, keycode, modifiers, grab_window, owner_events, pointer_mode,
  13160.              keyboard_mode)
  13161.       Display *display;
  13162.       int keycode;
  13163.       unsigned int modifiers;
  13164.       Window grab_window;
  13165.       Bool owner_events;
  13166.       int pointer_mode, keyboard_mode;
  13167.  
  13168.  
  13169. display   Specifies the connection to the X server.
  13170.  
  13171. keycode   Specifies the keycode.  This keycode maps to the
  13172.           specific key you want to grab.  You can pass
  13173.           either the keycode or the constant AnyKey.
  13174.  
  13175.  
  13176.  
  13177.  
  13178.  
  13179.  
  13180.                      December 18, 1987
  13181.  
  13182.  
  13183.  
  13184.  
  13185.  
  13186.                           - 192 -
  13187.  
  13188.  
  13189. modifiers Specifies the set of keymasks.  This mask is the
  13190.           bitwise inclusive OR of these keymask bits:
  13191.           ShiftMask, LockMask, ControlMask, Mod1Mask,
  13192.           Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.
  13193.  
  13194.           You can also pass the constant AnyModifier, which
  13195.           is equivalent to issuing the grab key request for
  13196.           all possible modifier combinations (including the
  13197.           combination of no modifiers).
  13198.  
  13199. grab_windowSpecifies the window ID of the window associated
  13200.           with the keys you want to grab.
  13201.  
  13202. owner_eventsSpecifies a boolean value of either True or
  13203.           False.
  13204.  
  13205. pointer_modeControls further processing of pointer events.
  13206.           You can pass one of these constants:  GrabModeSync
  13207.           or GrabModeAsync.
  13208.  
  13209. keyboard_modeControls further processing of keyboard events.
  13210.           You can pass one of these constants:  GrabModeSync
  13211.           or GrabModeAsync.
  13212.  
  13213. The XGrabKey function establishes a passive grab on the key-
  13214. board.  Consequently, in the future:
  13215.  
  13216. o    IF the specified key, which itself can be a modifier
  13217.      key, is pressed when the specified modifier keys are
  13218.      down (and no other keys are down),
  13219.  
  13220. o    AND EITHER the grab window is an ancestor of (or is)
  13221.      the focus window OR the grab window is a descendent of
  13222.      the focus window and contains the pointer,
  13223.  
  13224. o    AND these constraints are not satisfied for any ances-
  13225.      tor of grab_window,
  13226.  
  13227. o    THEN the keyboard is actively grabbed, as for XGrabKey-
  13228.      board, the last-keyboard-grab time is set to the time
  13229.      at which the key was pressed (as transmitted in the
  13230.      KeyPress event), and the KeyPress event is reported.
  13231.  
  13232. The interpretation of the remaining arguments is as for
  13233. XGrabKeyboard.  The active grab is terminated automatically
  13234. when the specified key has been released (independent of the
  13235. state of the modifier keys).
  13236.  
  13237. A modifiers of AnyModifier is equivalent to issuing the
  13238. request for all possible modifier combinations (including
  13239. the combination of no modifiers). It is not required that
  13240. all modifiers specified have currently assigned keycodes.  A
  13241. key of AnyKey is equivalent to issuing the request for all
  13242. possible keycodes.  Otherwise, the key must be in the range
  13243.  
  13244.  
  13245.  
  13246.                      December 18, 1987
  13247.  
  13248.  
  13249.  
  13250.  
  13251.  
  13252.                           - 193 -
  13253.  
  13254.  
  13255. specified by min_keycode and max_keycode in the connection
  13256. setup. Otherwise, a BadValue error is generated.
  13257.  
  13258. A BadAccess error is generated if some other client has
  13259. issued a XGrabKey with the same key combination on the same
  13260. window. When using AnyModifier or AnyKey, the request fails
  13261. completely and the X server generates a BadAccess error and
  13262. no grabs are established if there is a conflicting grab for
  13263. any combination.
  13264.  
  13265. The errors that can be generated by XGrabKey are BadAccess,
  13266. BadValue, and BadWindow.
  13267.  
  13268.  
  13269. Use XUngrabKey to ungrab a key. The definition for this
  13270. function is:
  13271.  
  13272. XUngrabKey(display, keycode, modifiers, ungrab_window)
  13273.       Display *display;
  13274.       int keycode;
  13275.       unsigned int modifiers;
  13276.       Window ungrab_window;
  13277.  
  13278.  
  13279. display   Specifies the connection to the X server.
  13280.  
  13281. keycode   Specifies the keycode.  This keycode maps to the
  13282.           specific key you want to ungrab.  You can pass
  13283.           either the keycode or the constant AnyKey.
  13284.  
  13285. modifiers Specifies the set of keymasks.  This mask is the
  13286.           bitwise inclusive OR of these keymask bits:
  13287.           ShiftMask, LockMask, ControlMask, Mod1Mask,
  13288.           Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.  You can
  13289.           also pass the constant AnyModifier, which is
  13290.           equivalent to issuing the ungrab key request for
  13291.           all possible modifier combinations (including the
  13292.           combination of no modifiers).
  13293.  
  13294. ungrab_windowSpecifies the window ID of the window associ-
  13295.           ated with the keys you want to ungrab.
  13296.  
  13297. The XUngrabKey function releases the key combination on the
  13298. specified window if it was grabbed by this client.  This
  13299. function has no effect on an active grab.  A modifiers of
  13300. AnyModifier is equivalent to issuing the request for all
  13301. possible modifier combinations (including the combination of
  13302. no modifiers).  A key of AnyKey is equivalent to issuing the
  13303. request for all possible nonmodifier key codes.
  13304.  
  13305. The error that can be generated by XUngrabKey is BadWindow.
  13306.  
  13307.  
  13308. Use XAllowEvents to allow further events to be processed
  13309.  
  13310.  
  13311.  
  13312.                      December 18, 1987
  13313.  
  13314.  
  13315.  
  13316.  
  13317.  
  13318.                           - 194 -
  13319.  
  13320.  
  13321. when the device has been frozen. The definition for this
  13322. function is:
  13323.  
  13324. XAllowEvents(display, event_mode, time)
  13325.       Display *display;
  13326.       int event_mode;
  13327.       Time time;
  13328.  
  13329.  
  13330. display   Specifies the connection to the X server.
  13331.  
  13332. event_modeSpecifies the event mode.  You can pass one of
  13333.           these constants:  AsyncPointer, SyncPointer,
  13334.           AsyncKeyboard, SyncKeyboard, ReplayPointer,
  13335.           ReplayKeyboard, AsyncBoth, or SyncBoth.
  13336.  
  13337. time      Specifies the time.  You can pass either a times-
  13338.           tamp, expressed in milliseconds, or the constant
  13339.           CurrentTime.
  13340.  
  13341. The XAllowEvents function releases some queued events if the
  13342. client has caused a device to freeze.  The function has no
  13343. effect if the specified time is earlier than the last-grab
  13344. time of the most recent active grab for the client, or if
  13345. the specified time is later than the current X server time.
  13346. The following describes the processing that occurs depending
  13347. on what constant you pass to the event_mode argument:
  13348.  
  13349. AsyncPointer
  13350.                     If the pointer is frozen by the client
  13351.                     the pointer event processing continues
  13352.                     as usual.  If the pointer is frozen
  13353.                     twice by the client on behalf of two
  13354.                     separate grabs, AsyncPointer thaws for
  13355.                     both.  AsyncPointer has no effect if the
  13356.                     pointer is not frozen by the client, but
  13357.                     the pointer need not be grabbed by the
  13358.                     client.
  13359.  
  13360.  
  13361.  
  13362.  
  13363.  
  13364.  
  13365.  
  13366.  
  13367.  
  13368. SyncPointer
  13369.                     If the pointer is frozen and actively
  13370.                     grabbed by the client, pointer event
  13371.                     processing continues normally until the
  13372.                     next ButtonPress or ButtonRelease event
  13373.                     is reported to the client.  At this
  13374.                     time, the pointer again appears to
  13375.                     freeze.  However, if the reported event
  13376.                     causes the pointer grab to be released,
  13377.                     the pointer does not freeze.  Sync-
  13378.                     Pointer has no effect if the pointer is
  13379.                     not frozen by the client or if the
  13380.                     pointer is not grabbed by the client.
  13381.  
  13382.  
  13383.  
  13384.  
  13385.  
  13386.  
  13387.  
  13388.  
  13389.  
  13390.  
  13391.  
  13392.  
  13393. ReplayPointer
  13394.                     If the pointer is actively grabbed by
  13395.                     the client and is frozen as the result
  13396.  
  13397.  
  13398.  
  13399.  
  13400.  
  13401.  
  13402.  
  13403.                      December 18, 1987
  13404.  
  13405.  
  13406.  
  13407.  
  13408.  
  13409.                           - 195 -
  13410.  
  13411.  
  13412.                     of an event having been sent to the
  13413.                     client (either from the activation of a
  13414.                     XGrabButton or from a previous XAl-
  13415.                     lowEvents with mode (SyncPointer, but
  13416.                     not from a XGrabPointer), the pointer
  13417.                     grab is released and that event is com-
  13418.                     pletely reprocessed.  This time, how-
  13419.                     ever, the function ignores any passive
  13420.                     grabs at or above (towards the root) the
  13421.                     grab_window of the grab just released.
  13422.                     The request has no effect if the pointer
  13423.                     is not grabbed by the client or if the
  13424.                     pointer is not frozen as the result of
  13425.                     an event.
  13426.  
  13427.  
  13428.  
  13429.  
  13430.  
  13431.  
  13432.  
  13433.  
  13434.  
  13435.  
  13436.  
  13437.  
  13438.  
  13439.  
  13440. AsyncKeyboard
  13441.                     If the keyboard is frozen by the client,
  13442.                     the keyboard event processing continues
  13443.                     as usual.  If the keyboard is frozen
  13444.                     twice by the client on behalf of two
  13445.                     separate grabs, AsyncKeyboard ``thaws''
  13446.                     for both.  AsyncKeyboard has no effect
  13447.                     if the keyboard is not frozen by the
  13448.                     client, but the keyboard need not be
  13449.                     grabbed by the client.
  13450.  
  13451.  
  13452.  
  13453.  
  13454.  
  13455.  
  13456.  
  13457.  
  13458.  
  13459. SyncKeyboard
  13460.                     If the keyboard is frozen and actively
  13461.                     grabbed by the client, keyboard event
  13462.                     processing continues as usual until the
  13463.                     next KeyPress or KeyRelease event is
  13464.                     reported to the client.  At this time,
  13465.                     the keyboard again appears to freeze.
  13466.                     However, if the reported event causes
  13467.                     the keyboard grab to be released, the
  13468.                     keyboard does not freeze.  SyncKeyboard
  13469.                     has no effect if the keyboard is not
  13470.                     frozen by the client or if the keyboard
  13471.                     is not grabbed by the client.
  13472.  
  13473.  
  13474.  
  13475.  
  13476.  
  13477.  
  13478.  
  13479.  
  13480.  
  13481.  
  13482.  
  13483.  
  13484. ReplayKeyboard
  13485.                     If the keyboard is actively grabbed by
  13486.                     the client and is frozen as the result
  13487.                     of an event having been sent to the
  13488.                     client (either from the activation of a
  13489.                     XGrabKey or from a previous XAllowEvents
  13490.                     with mode (SyncKeyboard, but not from a
  13491.                     XGrabKeyboard), the keyboard grab is
  13492.                     released and that event is completely
  13493.                     reprocessed.  This time, however, the
  13494.                     function ignores any passive grabs at or
  13495.                     above (towards the root) the grab_window
  13496.                     of the grab just released.  The request
  13497.                     has no effect if the keyboard is not
  13498.                     grabbed by the client or if the keyboard
  13499.                     is not frozen as the result of an event.
  13500.  
  13501.  
  13502.  
  13503.  
  13504.  
  13505.  
  13506.  
  13507.  
  13508.  
  13509.  
  13510.  
  13511.  
  13512.  
  13513.  
  13514.  
  13515.  
  13516.  
  13517.  
  13518.  
  13519.  
  13520.                      December 18, 1987
  13521.  
  13522.  
  13523.  
  13524.  
  13525.  
  13526.                           - 196 -
  13527.  
  13528.  
  13529. SyncBoth
  13530.                     If both pointer and keyboard are frozen
  13531.                     by the client, event processing (for
  13532.                     both devices) continues normally until
  13533.                     the next ButtonPress, ButtonRelease,
  13534.                     KeyPress, or KeyRelease event is
  13535.                     reported to the client for a grabbed
  13536.                     device (button event for the pointer,
  13537.                     key event for the keyboard), at which
  13538.                     time the devices again appear to freeze.
  13539.                     However, if the reported event causes
  13540.                     the grab to be released, then the dev-
  13541.                     ices do not freeze (but if the other
  13542.                     device is still grabbed, then a subse-
  13543.                     quent event for it will still cause both
  13544.                     devices to freeze). SyncBoth has no
  13545.                     effect unless both pointer and keyboard
  13546.                     are frozen by the client.  If the
  13547.                     pointer or keyboard is frozen twice by
  13548.                     the client on behalf of two separate
  13549.                     grabs, SyncBoth "thaws" for both (but a
  13550.                     subsequent freeze for SyncBoth will only
  13551.                     freeze each device once).
  13552.  
  13553.  
  13554.  
  13555.  
  13556.  
  13557.  
  13558.  
  13559.  
  13560.  
  13561.  
  13562.  
  13563.  
  13564.  
  13565.  
  13566.  
  13567.  
  13568.  
  13569.  
  13570.  
  13571.  
  13572.  
  13573.  
  13574. AsyncBoth
  13575.                     If the pointer and the keyboard are
  13576.                     frozen by the client, event processing
  13577.                     (for both devices) continues normally.
  13578.                     If a device is frozen twice by the
  13579.                     client on behalf of two separate grabs,
  13580.                     AsyncBoth "thaws" for both.  AsyncBoth
  13581.                     has no effect unless both pointer and
  13582.                     keyboard are frozen by the client.
  13583.  
  13584.  
  13585.  
  13586.  
  13587.  
  13588.  
  13589.  
  13590.  
  13591.  
  13592.  
  13593. AsyncPointer, SyncPointer, and ReplayPointer have no effect
  13594. on the processing of keyboard events.  AsyncKeyboard, SyncK-
  13595. eyboard, and ReplayKeyboard have no effect on the processing
  13596. of pointer events.  It is possible for both a pointer grab
  13597. and a keyboard grab (by the same or different clients) to be
  13598. active simultaneously.  If a device is frozen on behalf of
  13599. either grab, no event processing is performed for the dev-
  13600. ice.  It is possible for a single device to be frozen
  13601. because of both grabs.  In this case, the freeze must be
  13602. released on behalf of both grabs before events can again be
  13603. processed.
  13604.  
  13605. The error that can be generated by XAllowEvents is BadValue.
  13606.  
  13607. 7.6.  Grabbing the Server
  13608.  
  13609. Xlib provides functions with which you can grab and ungrab
  13610. the server.  These functions can be used to control process-
  13611. ing of output on other connections by the window system
  13612. server.  No processing of requests or close downs on any
  13613. other connection will occur while the server is grabbed.  A
  13614. client closing its connection automatically ungrabs the
  13615.  
  13616.  
  13617.                      December 18, 1987
  13618.  
  13619.  
  13620.  
  13621.  
  13622.  
  13623.                           - 197 -
  13624.  
  13625.  
  13626. server.  Although grabbing the server is highly discouraged,
  13627. it is sometimes necessary.
  13628.  
  13629.  
  13630. Use XGrabServer to grab the server. The definition for this
  13631. function is:
  13632.  
  13633. XGrabServer(display)
  13634.       Display *display;
  13635.  
  13636.  
  13637. display   Specifies the connection to the X server.
  13638.  
  13639. The XGrabServer function disables processing of requests and
  13640. close-downs on all other connections than the one this
  13641. request arrived on.  It is recommended that you not grab the
  13642. X server any more than is absolutely necessary.
  13643.  
  13644.  
  13645. Use XUngrabServer to ungrab the server. The definition for
  13646. this function is:
  13647.  
  13648. XUngrabServer(display)
  13649.       Display *display;
  13650.  
  13651.  
  13652. display   Specifies the connection to the X server.
  13653.  
  13654. The XUngrabServer function restarts processing of requests
  13655. and close-downs on other connections.  You should avoid
  13656. grabbing the server as much as possible.
  13657.  
  13658. 7.7.  Miscellaneous Control Function
  13659.  
  13660. This section discusses how to:
  13661.  
  13662. o    Control the input focus
  13663.  
  13664. o    Control the pointer
  13665.  
  13666. o    Kill clients
  13667.  
  13668. 7.7.1.  Controlling the Input Focus
  13669.  
  13670. Xlib provides functions with which you can move the pointer
  13671. position as well as set and get the input focus.
  13672.  
  13673.  
  13674. Use XWarpPointer to move the pointer to an arbitrary point
  13675. on the screen. The definition for this function is:
  13676.  
  13677.  
  13678.  
  13679.  
  13680.  
  13681.  
  13682.  
  13683.                      December 18, 1987
  13684.  
  13685.  
  13686.  
  13687.  
  13688.  
  13689.                           - 198 -
  13690.  
  13691.  
  13692. XWarpPointer(display, src_w, dest_w, src_x, src_y, src_width, src_height, dest_x,
  13693.                 dest_y)
  13694.         Display *display;
  13695.         Window src_w, dest_w;
  13696.         int src_x, src_y;
  13697.         unsigned int src_width, src_height;
  13698.         int dest_x, dest_y;
  13699.  
  13700.  
  13701. display   Specifies the connection to the X server.
  13702.  
  13703. src_w     Specifies the window ID of the source window.  You
  13704.           can pass the window ID or the constant None.
  13705.  
  13706. dest_w    Specifies the window ID of the destination window.
  13707.           You can pass the window ID or the constant None.
  13708.  
  13709. src_x
  13710. src_y     Specify the x and y coordinates within the source
  13711.           window.
  13712.  
  13713. src_width
  13714. src_heightSpecify the width and height of the source window.
  13715.  
  13716. dest_x
  13717. dest_y    Specify the x and y coordinates within the desti-
  13718.           nation window.
  13719.  
  13720. The XWarpPointer function moves the pointer to the coordi-
  13721. nates specified by the dest_x and dest_y arguments, relative
  13722. to the destination window's origin.  If the destination win-
  13723. dow is None, the pointer is moved by offsets specified by
  13724. the dest_x and dest_y coordinates.  There is seldom any rea-
  13725. son for calling this function. The pointer should normally
  13726. be left to the mouse.  If you do use this function, however,
  13727. it generates events just as if the user had instantaneously
  13728. moved the pointer from one position to another.  Note that
  13729. you cannot use XWarpPointer to move the pointer outside the
  13730. confine_to window of an active pointer grab.  An attempt to
  13731. do so will only move the pointer as far as the closest edge
  13732. of the confine_to window.
  13733.  
  13734. If the src_w argument is None, the move is independent of
  13735. the current pointer position.  However, if src_w is a win-
  13736. dow, the move only takes place if the pointer is currently
  13737. contained in a visible portion of the specified rectangle of
  13738. the src_w.  If dest_w is None, the function moves the
  13739. pointer by offsets (dest_x, dest_y) relative to the current
  13740. position of the pointer.  If dest_w is a window, the func-
  13741. tion moves the pointer to (dest_x, dest_y) relative to the
  13742. origin of dest_w.  However, if src_w is not None, the move
  13743. only takes place if the pointer is currently contained in a
  13744. visible portion of the specified rectangle of the src_w.
  13745.  
  13746.  
  13747.  
  13748.  
  13749.                      December 18, 1987
  13750.  
  13751.  
  13752.  
  13753.  
  13754.  
  13755.                           - 199 -
  13756.  
  13757.  
  13758. The coordinates passed to src_x and src_y are relative to
  13759. the source window's origin.  If src_height is zero (0), the
  13760. function replaces it with the current height of the source
  13761. window minus src_y.  If src_width is zero (0), the function
  13762. replaces it with the current width of the source window
  13763. minus src_x.
  13764.  
  13765. The error that can be generated by XWarpPointer is BadWin-
  13766. dow.
  13767.  
  13768.  
  13769. Use XSetInputFocus to set the input focus. The definition
  13770. for this function is:
  13771.  
  13772. XSetInputFocus(display, focus, revert_to, time)
  13773.       Display *display;
  13774.       Window focus;
  13775.       int revert_to;
  13776.       Time time;
  13777.  
  13778.  
  13779. display   Specifies the connection to the X server.
  13780.  
  13781. focus     Specifies the window ID.  This is the window in
  13782.           which you want to set the input focus.  You can
  13783.           pass the window ID or one of the constants Poin-
  13784.           terRoot or None.
  13785.  
  13786. revert_to Specifies which window the input focus reverts to
  13787.           if the window becomes not viewable.  You can pass
  13788.           one of these constants:  RevertToParent, RevertTo-
  13789.           PointerRoot, or RevertToNone.
  13790.  
  13791. time      Specifies the time.  You can pass either a times-
  13792.           tamp, expressed in milliseconds, or the constant
  13793.           CurrentTime.
  13794.  
  13795. The XSetInputFocus function changes the input focus and the
  13796. last-focus-change time.  The function has no effect if the
  13797. specified time is earlier than the current last-focus-change
  13798. time or is later than the current X server time.  Otherwise,
  13799. the last-focus-change time is set to the specified time and
  13800. the CurrentTime replaced by the current X server time.  This
  13801. function causes the X server to generate FocusIn and Focu-
  13802. sOut events.
  13803.  
  13804. Depending on what value you assign to the focus argument,
  13805. XSetInputFocus executes as follows:
  13806.  
  13807. o    If you assign None to the focus argument, all keyboard
  13808.      events are discarded until you set a new focus window.
  13809.      In this case, the revert_to argument is ignored.
  13810.  
  13811.  
  13812.  
  13813.  
  13814.  
  13815.                      December 18, 1987
  13816.  
  13817.  
  13818.  
  13819.  
  13820.  
  13821.                           - 200 -
  13822.  
  13823.  
  13824. o    If you assign a window ID to the focus argument, it
  13825.      becomes the keyboard's focus window.  If a generated
  13826.      keyboard event would normally be reported to this win-
  13827.      dow or one of its inferiors, the event is reported nor-
  13828.      mally. Otherwise, the event is reported relative to the
  13829.      focus window.
  13830.  
  13831. o    If you assign PointerRoot to the focus argument, the
  13832.      focus window is dynamically taken to be the root window
  13833.      of whatever screen the pointer is on at each keyboard
  13834.      event. In this case, the revert_to argument is ignored.
  13835.  
  13836. The specified focus window must be viewable at the time
  13837. XSetInputFocus is called.  Otherwise, a BadMatch error is
  13838. generated.  If the focus window later becomes not viewable,
  13839. the X server evaluates the revert_to argument to determine
  13840. the new focus window:
  13841.  
  13842. o    If you assign RevertToParent to the revert_to argument,
  13843.      the focus reverts to the parent (or the closest view-
  13844.      able ancestor), and the new revert_to value is taken to
  13845.      be RevertToNone.
  13846.  
  13847. o    If you assign RevertToPointerRoot or RevertToNone to
  13848.      the revert_to argument, the focus reverts to that
  13849.      value.  When the focus reverts, the X server generates
  13850.      FocusIn and FocusOut events, but the last-focus-change
  13851.      time is not affected.
  13852.  
  13853. The errors that can be generated by XSetInputFocus are
  13854. BadWindow and BadValue.
  13855.  
  13856.  
  13857. Use XGetInputFocus to obtain the current input focus. The
  13858. definition for this function is:
  13859.  
  13860. XGetInputFocus(display, focus_return, revert_to_return)
  13861.       Display *display;
  13862.       Window *focus_return;
  13863.       int *revert_to_return;
  13864.  
  13865.  
  13866. display   Specifies the connection to the X server.
  13867.  
  13868. focus_returnReturns the focus window ID, the constant Poin-
  13869.           terRoot, or the constant None.
  13870.  
  13871. revert_to_returnReturns the current focus state.  The func-
  13872.           tion can return one of these constants:  RevertTo-
  13873.           Parent, RevertToPointerRoot, or RevertToNone.
  13874.  
  13875. The XGetInputFocus function returns the focus window ID and
  13876. the current focus state.
  13877.  
  13878.  
  13879.  
  13880.  
  13881.                      December 18, 1987
  13882.  
  13883.  
  13884.  
  13885.  
  13886.  
  13887.                           - 201 -
  13888.  
  13889.  
  13890. 7.7.2.  Controlling the Pointer
  13891.  
  13892. Xlib provides functions with which you can change the
  13893. pointer control or can get the current pointer control
  13894. parameters.
  13895.  
  13896.  
  13897. Use XChangePointerControl to control the interactive feel of
  13898. the pointer device.  The definition for this function is:
  13899.  
  13900. XChangePointerControl(display, do_accel, do_threshold, accel_numerator,
  13901.                         accel_denominator, threshold)
  13902.       Display *display;
  13903.       Bool do_accel, do_threshold;
  13904.       int accel_numerator, accel_denominator;
  13905.       int threshold;
  13906.  
  13907.  
  13908. display   Specifies the connection to the X server.
  13909.  
  13910. do_accel  Specifies a boolean value that controls whether
  13911.           the values for the accel_numerator or
  13912.           accel_denominator are set.  You can pass one of
  13913.           these constants:  True or False.
  13914.  
  13915. do_thresholdSpecifies a boolean value that controls whether
  13916.           the value for the accel_numerator or
  13917.           accel_denominator are set.  You can pass one of
  13918.           these constants:  True or False.
  13919.  
  13920. accel_numeratorSpecifies the numerator for the acceleration
  13921.           multiplier.
  13922.  
  13923. accel_denominatorSpecifies the denominator for the accelera-
  13924.           tion multiplier.
  13925.  
  13926. threshold Specifies the acceleration threshold.
  13927.  
  13928. The XChangePointerControl function defines how the pointing
  13929. device moves.  The acceleration, expressed as a fraction, is
  13930. a multiplier for movement. For example, specifying 3/1 means
  13931. the pointer moves three times as fast as normal.  The frac-
  13932. tion may be rounded arbitrarily by the X server. Accelera-
  13933. tion only takes effect if the pointer moves more than thres-
  13934. hold pixels at once and only applies to the amount beyond
  13935. the value in the threshold argument.  Setting a value to -1
  13936. restores the default.  The values of the do_accel and
  13937. do_threshold arguments must be nonzero for the pointer
  13938. values to be set.  Otherwise, the parameters will be
  13939. unchanged.  Negative values generate a BadValue error, as
  13940. does a zero value for the accel_denominator argument.
  13941.  
  13942. The error that can be generated by XChangePointerControl is
  13943. BadValue.
  13944.  
  13945.  
  13946.  
  13947.                      December 18, 1987
  13948.  
  13949.  
  13950.  
  13951.  
  13952.  
  13953.                           - 202 -
  13954.  
  13955.  
  13956. Use XGetPointerControl to get the current parameters set for
  13957. the pointer. The definition for this function is:
  13958.  
  13959. XGetPointerControl(display, accel_numerator_return, accel_denominator_return,
  13960.                        threshold_return)
  13961.       Display *display;
  13962.       int *accel_numerator_return, *accel_denominator_return;
  13963.       int *threshold_return;
  13964.  
  13965.  
  13966. display   Specifies the connection to the X server.
  13967.  
  13968. accel_numerator_returnReturns the numerator for the
  13969.           acceleration multiplier.
  13970.  
  13971. accel_denominator_returnReturns the denominator for the
  13972.           acceleration multiplier.
  13973.  
  13974. threshold_returnReturns the acceleration threshold.
  13975.  
  13976. The XGetPointerControl function returns the pointer's
  13977. current acceleration multiplier and acceleration threshold.
  13978.  
  13979. 7.7.3.  Killing Clients
  13980.  
  13981. Xlib provides functions with which you can control the life
  13982. time of resources owned by a client or can cause the connec-
  13983. tion to a client to be destroyed.
  13984.  
  13985.  
  13986. Use XSetCloseDownMode to change the close down mode of a
  13987. client. The definition for this function is:
  13988.  
  13989. XSetCloseDownMode(display, close_mode)
  13990.       Display *display;
  13991.       int close_mode;
  13992.  
  13993.  
  13994. display   Specifies the connection to the X server.
  13995.  
  13996. close_modeSpecifies the client close down mode you want to
  13997.           change.  You can pass one of these constants:
  13998.           DestroyAll, RetainPermanent, or RetainTemporary.
  13999.  
  14000. The XSetCloseDownMode defines what will happen to the
  14001. client's resources at connection close.  A connection starts
  14002. in DestroyAll mode.  See the Section 2.6 for information on
  14003. what happens to the client's resources when the close_mode
  14004. argument is one of the valid constants.
  14005.  
  14006. The error that can be generated by XSetCloseDownMode is Bad-
  14007. Value.
  14008.  
  14009.  
  14010.  
  14011.  
  14012.  
  14013.                      December 18, 1987
  14014.  
  14015.  
  14016.  
  14017.  
  14018.  
  14019.                           - 203 -
  14020.  
  14021.  
  14022. Use XKillClient to destroy a client. The definition for this
  14023. function is:
  14024.  
  14025. XKillClient(display, resource)
  14026.       Display *display;
  14027.       XID resource;
  14028.  
  14029.  
  14030. display   Specifies the connection to the X server.
  14031.  
  14032. resource  Specifies any resource associated with the client
  14033.           you want to destroy.  You can also pass the con-
  14034.           stant AllTemporary.
  14035.  
  14036. The XKillClient function forces a close-down of the client
  14037. that created the resource if a valid resource is specified.
  14038. If the client has already terminated in either RetainPer-
  14039. manent or RetainTemporary mode, all of the client's
  14040. resources are destroyed.  If AllTemporary is specified, the
  14041. resources of all clients that have terminated in RetainTem-
  14042. porary are destroyed.  See Section 2.6 for further informa-
  14043. tion.
  14044.  
  14045. The error that can be generated by XKillClient is BadValue.
  14046.  
  14047. 7.8.  Manipulating Keyboard Settings
  14048.  
  14049. Xlib provides functions with which you can change the key-
  14050. board control, obtain a list of the auto-repeat keys, turn
  14051. keyboard auto-repeat on or off, ring the bell, set or obtain
  14052. the pointer button or keyboard mapping, and obtain a bit
  14053. vector for the keyboard.
  14054.  
  14055. This section discusses the user preference options of bell,
  14056. keyclick, mouse behavior, and so on.  The default values for
  14057. many of these functions are determined by command line argu-
  14058. ments to the X server, and on UNIX-based systems are typi-
  14059. cally set in /etc/ttys.  Not all implementations will actu-
  14060. ally be able to control all of these parameters.
  14061.  
  14062.  
  14063. Use XChangeKeyboardControl to change control from a key-
  14064. board. The definition for this function is:
  14065.  
  14066. XChangeKeyboardControl(display, value_mask, values)
  14067.       Display *display;
  14068.       unsigned long value_mask;
  14069.       XKeyboardControl *values;
  14070.  
  14071.  
  14072. display   Specifies the connection to the X server.
  14073.  
  14074.  
  14075.  
  14076.  
  14077.  
  14078.  
  14079.                      December 18, 1987
  14080.  
  14081.  
  14082.  
  14083.  
  14084.  
  14085.                           - 204 -
  14086.  
  14087.  
  14088. value_maskSpecifies one value for each one bit in the mask
  14089.           (least to most significant bit). The values are
  14090.           associated with the set of keys for the previously
  14091.           specified keyboard.
  14092.  
  14093. values    Specifies a pointer to the structure XKeyboardCon-
  14094.           trol.
  14095.  
  14096. The XChangeKeyboardControl function controls the keyboard
  14097. characteristics defined by the XKeyboardControl structure.
  14098. The values argument specifies which values are to be
  14099. changed. The value_mask contains one value for each one bit
  14100. in the mask (least to most significant bit).  This function
  14101. operates on a XKeyboardControl structure:
  14102. /* masks for ChangeKeyboardControl */
  14103.  
  14104. #define KBKeyClickPercent     (1L<<0)
  14105. #define KBBellPercent         (1L<<1)
  14106. #define KBBellPitch           (1L<<2)
  14107. #define KBBellDuration        (1L<<3)
  14108. #define KBLed                 (1L<<4)
  14109. #define KBLedMode             (1L<<5)
  14110. #define KBKey                 (1L<<6)
  14111. #define KBAutoRepeatMode      (1L<<7)
  14112.  
  14113. typedef struct {
  14114.      int key_click_percent;
  14115.      int bell_percent;
  14116.      int bell_pitch;
  14117.      int bell_duration;
  14118.      int led;
  14119.      int led_mode
  14120.      int key;
  14121.      int auto_repeat_mode;    /* AutoRepeatModeOff, AutoRepeatModeOn,
  14122.                               AutoRepeatModeDefault */
  14123. } XKeyboardControl;
  14124.  
  14125. The following describes each of the members of the XKey-
  14126. boardControl structure.
  14127.  
  14128. The key_click_percent member sets the volume for key clicks
  14129. between 0 (off) and 100 (loud) inclusive, if possible. A
  14130. setting of -1 restores the default.  Other negative values
  14131. generate a BadValue error.
  14132.  
  14133. The bell_percent sets the base volume for the bell between 0
  14134. (off) and 100 (loud) inclusive, if possible. A setting of -1
  14135. restores the default.  Other negative values generate a Bad-
  14136. Value error.  The bell_pitch member sets the pitch (speci-
  14137. fied in Hz) of the bell, if possible.  A setting to -1
  14138. restores the default.  Other negative values generate a Bad-
  14139. Value error.  The bell_duration member sets the duration,
  14140. specified in milliseconds, of the bell, if possible. A set-
  14141. ting to -1 restores the default.  Other negative values
  14142.  
  14143.  
  14144.  
  14145.                      December 18, 1987
  14146.  
  14147.  
  14148.  
  14149.  
  14150.  
  14151.                           - 205 -
  14152.  
  14153.  
  14154. generate a BadValue error.
  14155.  
  14156. If both the led_mode and led members are specified, the
  14157. state of those LEDs are changed, if possible. If only
  14158. led_mode is specified, the state of all LEDs are changed, if
  14159. possible. At most 32 LEDs numbered from one are supported.
  14160. No standard interpretation of LEDs is defined.  A BadMatch
  14161. error is generated if an led is specified without an
  14162. led_mode.
  14163.  
  14164. If both the auto_repeat_mode and key members are specified,
  14165. the auto_repeat_mode of that key is changed, if possible
  14166. (where LED is the ordinal number of the LED to be changed,
  14167. not a mask). If only auto_repeat_mode is specified, the glo-
  14168. bal auto_repeat mode for the entire keyboard is changed, if
  14169. possible, and does not affect the per_key settings.  A Bad-
  14170. Match error is generated if a key is specified without an
  14171. auto_repeat_mode.
  14172.  
  14173. A bell generator connected with the console but not directly
  14174. on a keyboard is treated as if it were part of the main key-
  14175. board.  The order in which controls are verified and altered
  14176. is server-dependent.  If an error is generated, a subset of
  14177. the controls may have been altered.
  14178.  
  14179. The errors that can be generated by XChangeKeyboardControl
  14180. are BadMatch and BadValue.
  14181.  
  14182.  
  14183. Use XGetKeyboardControl to obtain the current control values
  14184. for the keyboard.  The definition for this function is:
  14185.  
  14186. XGetKeyboardControl(display, values_return)
  14187.       Display *display;
  14188.       XKeyboardState *values_return;
  14189.  
  14190.  
  14191. display   Specifies the connection to the X server.
  14192.  
  14193. values_returnReturns the current keyboard parameter in the
  14194.           specified XKeyboardState structure.
  14195.  
  14196. The XGetKeyboardControl function returns the current control
  14197. values for the keyboard to the XKeyboardState structure.
  14198. The members of this structure are:
  14199.  
  14200. typedef struct {
  14201.           int key_click_percent;
  14202.           int bell_percent;
  14203.           unsigned int bell_pitch, bell_duration;
  14204.           unsigned long led_mask;
  14205.           int global_auto_repeat;
  14206.           char auto_repeats[32];
  14207.           } XKeyboardState;
  14208.  
  14209.  
  14210.  
  14211.                      December 18, 1987
  14212.  
  14213.  
  14214.  
  14215.  
  14216.  
  14217.                           - 206 -
  14218.  
  14219.  
  14220. For the LEDs, the least significant bit of led_mask
  14221. corresponds to LED one, and each one bit in led_mask indi-
  14222. cates an LED that is lit.  The auto_repeats member is a bit
  14223. vector. Each one bit indicates that auto-repeat is enabled
  14224. for the corresponding key.  The vector is represented as 32
  14225. bytes. Byte N (from 0) contains the bits for keys 8N to
  14226. 8N+7, with the least significant bit in the byte represent-
  14227. ing key 8N.  The global_auto_repeat member can be set to one
  14228. of the constants AutoRepeatModeOn or AutoRepeatModeOff.
  14229.  
  14230.  
  14231. Use XAutoRepeatOn to turn on the keyboard auto-repeat. The
  14232. definition for this function is:
  14233.  
  14234. XAutoRepeatOn(display)
  14235.       Display *display;
  14236.  
  14237.  
  14238. display   Specifies the connection to the X server.
  14239.  
  14240. The XAutoRepeatOn function turns on auto-repeat for the key-
  14241. board on the specified display.
  14242.  
  14243.  
  14244. Use XAutoRepeatOff to turn off the keyboard auto-repeat. The
  14245. definition for this function is:
  14246.  
  14247. XAutoRepeatOff(display)
  14248.       Display *display;
  14249.  
  14250.  
  14251. display   Specifies the connection to the X server.
  14252.  
  14253. The XAutoRepeatOff function turns off auto-repeat for the
  14254. keyboard on the specified display.
  14255.  
  14256.  
  14257. Use XBell to ring the bell. The definition for this function
  14258. is:
  14259.  
  14260. XBell(display, percent)
  14261.       Display *display;
  14262.       int percent;
  14263.  
  14264.  
  14265. display   Specifies the connection to the X server.
  14266.  
  14267. percent   Specifies the base volume for the bell, which can
  14268.           range from -100 to 100 inclusive.
  14269.  
  14270. The XBell function rings the bell on the keyboard on the
  14271. specified display, if possible.  The specified volume is
  14272. relative to the base volume for the keyboard.  If the value
  14273. for the percent argument is not in the range -100 to 100
  14274.  
  14275.  
  14276.  
  14277.                      December 18, 1987
  14278.  
  14279.  
  14280.  
  14281.  
  14282.  
  14283.                           - 207 -
  14284.  
  14285.  
  14286. inclusive, a BadValue error is generated.  The volume at
  14287. which the bell is rung when the percent argument is nonnega-
  14288. tive is:
  14289.  
  14290.      base - [(base * percent) / 100] + percent
  14291.  
  14292. The volume at which the bell is rung when the percent argu-
  14293. ment is negative is:
  14294.  
  14295.      base + [(base * percent) / 100]
  14296.  
  14297. To change the base volume of the bell for this keyboard, use
  14298. XChangeKeyboardControl.
  14299.  
  14300.  
  14301. Use XSetPointerMapping to set the mapping of buttons on the
  14302. pointer.  The definition for this function is:
  14303.  
  14304. int XSetPointerMapping(display, map, nmap)
  14305.       Display *display;
  14306.       unsigned char map[];
  14307.       int nmap;
  14308.  
  14309.  
  14310. display   Specifies the connection to the X server.
  14311.  
  14312. map       Specifies the mapping list.
  14313.  
  14314. nmap      Specifies the number of items in mapping list.
  14315.  
  14316. The XSetPointerMapping function sets the mapping of the
  14317. pointer and causes the X server to generate a MappingNotify
  14318. event on a status of MappingSuccess.  Elements of the list
  14319. are indexed starting from one.  The length of the list must
  14320. be the same as XGetPointerMapping would return.  Otherwise,
  14321. a BadValue error is generated.  The index is a core button
  14322. number, and the element of the list defines the effective
  14323. number.  A zero element disables a button, and elements are
  14324. not restricted in value by the number of physical buttons.
  14325. However, no two elements can have the same nonzero value.
  14326. Otherwise, a BadValue error is generated.  If any of the
  14327. buttons to be altered are currently in the down state, the
  14328. status reply is MappingBusy and the mapping is not changed.
  14329. This function returns either MappingSuccess or MappingBusy.
  14330.  
  14331.  
  14332. Use XGetPointerMapping to get the pointer mapping.  The
  14333. definition for this function is:
  14334.  
  14335. int XGetPointerMapping(display, map, nmap)
  14336.       Display *display;
  14337.       unsigned char map[];
  14338.       int nmap;
  14339.  
  14340.  
  14341.  
  14342.  
  14343.                      December 18, 1987
  14344.  
  14345.  
  14346.  
  14347.  
  14348.  
  14349.                           - 208 -
  14350.  
  14351.  
  14352. display   Specifies the connection to the X server.
  14353.  
  14354. map       Specifies the mapping list.
  14355.  
  14356. nmap      Specifies the number of items in mapping list.
  14357.  
  14358. The XGetPointerMapping function returns the current mapping
  14359. of the pointer.  Elements of the list are indexed starting
  14360. from one.  The length of the list indicates the number of
  14361. physical buttons.  The nominal mapping for a pointer is the
  14362. identity mapping: map[i]=i.
  14363.  
  14364.  
  14365.  
  14366. Use XQueryKeymap to obtain a bit vector for the keyboard.
  14367. The definition for this function is:
  14368.  
  14369. XQueryKeymap(display, keys_return)
  14370.       Display *display;
  14371.       char keys_return[32];
  14372.  
  14373.  
  14374. display   Specifies the connection to the X server.
  14375.  
  14376. keys_returnReturns an array of bytes that identifies which
  14377.           keys are pressed down.  Each bit represents one
  14378.           key of the keyboard.
  14379.  
  14380. The XQueryKeymap function returns a bit vector for the key-
  14381. board, where each one bit indicates that the corresponding
  14382. key is currently pressed down.  The vector is represented as
  14383. 32 bytes.  Byte N (from 0) contains the bits for keys 8N to
  14384. 8N+7 with the least significant bit in the byte representing
  14385. key 8N.
  14386.  
  14387. 7.9.  Manipulating the Keyboard Encoding
  14388.  
  14389.  
  14390. A KeyCode represents a physical (or logical) key. Keycodes
  14391. lie in the inclusive range [8,255]. A keycode value carries
  14392. no intrinsic information, although server implementors may
  14393. attempt to encode geometry (for example, matrix) information
  14394. in some fashion so that it can be interpreted in a server-
  14395. dependent fashion.  The mapping between keys and keycodes
  14396. cannot be changed.
  14397.  
  14398. A KeySym is an encoding of a symbol on the cap of a key. The
  14399. set of defined KeySyms include the ISO Latin character sets
  14400. (1-4), Katakana, Arabic, Cyrillic, Greek, Technical, Spe-
  14401. cial, Publishing, APL, Hebrew, and a special miscellany of
  14402. keys found on keyboards (RETURN, HELP, TAB, and so on). To
  14403. the extent possible, these sets are derived from interna-
  14404. tional standards. In areas where no standards exist, some of
  14405. these sets are derived from Digital standards.  The list of
  14406.  
  14407.  
  14408.  
  14409.                      December 18, 1987
  14410.  
  14411.  
  14412.  
  14413.  
  14414.  
  14415.                           - 209 -
  14416.  
  14417.  
  14418. defined symbols can be found in the <X11/keysymdef.h> header
  14419. file.  Unfortunately, some C preprocessors have limits on
  14420. the number of defined symbols.  If you must use keysyms not
  14421. in the Latin 1-4, Greek, and miscellany classes, you may
  14422. have to define a symbol for those sets.  Most applications
  14423. usually only include <X11/keysym.h>, which defines symbols
  14424. for ISO Latin 1-4, Greek, and Miscellany.
  14425.  
  14426. A list of KeySyms is associated with each KeyCode. The
  14427. length of the list can vary with each KeyCode. The list is
  14428. intended to convey the set of symbols on the corresponding
  14429. key. By convention, if the list contains a single KeySym and
  14430. if that KeySym is alphabetic and case distinction is
  14431. relevant for it, then it should be treated as equivalent to
  14432. a two-element list of the lowercase and uppercase KeySyms.
  14433. For example, if the list contains the single KeySym for
  14434. uppercase A, the client should treat it as if it were a pair
  14435. with lowercase a as the first KeySym and uppercase A as the
  14436. second KeySym.
  14437.  
  14438. For any KeyCode, the first KeySym in the list should be
  14439. chosen as the interpretation of a KeyPress when no modifier
  14440. keys are down.  The second KeySym in the list normally
  14441. should be chosen when the Shift modifier is on, or when the
  14442. Lock modifier is on and Lock is interpreted as ShiftLock.
  14443. When the Lock modifier is on and is interpreted as CapsLock,
  14444. it is suggested that the Shift modifier first be applied to
  14445. choose a KeySym, but if that KeySym is lowercase alphabetic,
  14446. the corresponding uppercase KeySym should be used instead.
  14447. Other interpretations of CapsLock are possible; for example,
  14448. it may be viewed as equivalent to ShiftLock, but only apply-
  14449. ing when the first KeySym is lowercase alphabetic and the
  14450. second KeySym is the corresponding uppercase alphabetic. No
  14451. interpretation of KeySyms beyond the first two in a list is
  14452. suggested here. No spatial geometry of the symbols on the
  14453. key is defined by their order in the KeySym list, although a
  14454. geometry might be defined on a vendor-specific basis.  The X
  14455. server does not use the mapping between KeyCodes and
  14456. KeySyms.  Rather, it stores it merely for reading and writ-
  14457. ing by clients.
  14458.  
  14459.                             Note
  14460.  
  14461.      The simple interface, XLookupString will perform
  14462.      simple translation of a key event to an ASCII
  14463.      string. Keyboard related utilities are discussed
  14464.      in Chapter 10.
  14465.  
  14466.  
  14467.  
  14468. Use XGetKeyboardMapping to obtain the symbols for the speci-
  14469. fied number of keycodes.  The definition for this function
  14470. is:
  14471.  
  14472.  
  14473.  
  14474.  
  14475.                      December 18, 1987
  14476.  
  14477.  
  14478.  
  14479.  
  14480.  
  14481.                           - 210 -
  14482.  
  14483.  
  14484. KeySym *XGetKeyboardMapping(display, first_keycode_wanted, keycode_count,
  14485.                             keysyms_per_keycode_return)
  14486.       Display *display;
  14487.       KeyCode first_keycode_wanted;
  14488.       int keycode_count;
  14489.       int *keysyms_per_keycode_return;
  14490.  
  14491.  
  14492. display   Specifies the connection to the X server.
  14493.  
  14494. first_keycode_wantedSpecifies the first keycode that is to
  14495.           be returned.
  14496.  
  14497. keycode_countSpecifies the number of keycodes that are to be
  14498.           returned.
  14499.  
  14500. keysyms_per_keycode_returnReturns the number of keysyms per
  14501.           keycode.
  14502.  
  14503. The XGetKeyboardMapping function, starting with
  14504. first_keycode, returns the symbols for the specified number
  14505. of keycodes.  The value specified in the first_keycode argu-
  14506. ment must be greater than or equal to min_keycode as
  14507. returned in the Display structure at connection setup. Oth-
  14508. erwise, a BadValue error is generated.  In addition, the
  14509. following expression must be less than or equal to
  14510. max_keycode as returned in the Display structure at connec-
  14511. tion setup. If this is not the case, a BadValue error is
  14512. generated.
  14513.  
  14514.  
  14515.         first_keycode + keycode_count - 1
  14516.  
  14517. The number of elements in the keysyms list is:
  14518.  
  14519.  
  14520.         keycode_count * keysyms_per_keycode_return
  14521.  
  14522. Then, KeySym number N, counting from zero, for keycode K has
  14523. an index, counting from zero, of the following in KeySym:
  14524.  
  14525.         (K - first_code) * keysyms_per_code + N
  14526.  
  14527. The keysyms_per_keycode_return value is chosen arbitrarily
  14528. by the X server to be large enough to report all requested
  14529. symbols. A special KeySym value of NoSymbol is used to fill
  14530. in unused elements for individual keycodes.
  14531.  
  14532. Use XFree to free the storage returned by XGetKeyboardMap-
  14533. ping.  (See Section 2.4 for further information.)
  14534.  
  14535. The other error that can be generated by XGetKeyboardMapping
  14536. is BadValue.
  14537.  
  14538.  
  14539.  
  14540.  
  14541.                      December 18, 1987
  14542.  
  14543.  
  14544.  
  14545.  
  14546.  
  14547.                           - 211 -
  14548.  
  14549.  
  14550. Use XChangeKeyboardMapping to change the keyboard mapping.
  14551. The definition for this function is:
  14552.  
  14553. XChangeKeyboardMapping(display, first_keycode, keysyms_per_keycode, keysyms, num_codes)
  14554.       Display *display;
  14555.       int first_keycode;
  14556.       int keysyms_per_keycode;
  14557.       KeySym *keysyms;
  14558.       int num_codes;
  14559.  
  14560.  
  14561. display   Specifies the connection to the X server.
  14562.  
  14563. first_keycodeSpecifies the first keycode that is to be
  14564.           changed.
  14565.  
  14566. keysyms_per_keycodeSpecifies the keysyms that are to be
  14567.           used.
  14568.  
  14569. keysyms   Specifies a pointer to an array of keysyms.
  14570.  
  14571. num_codes Specifies the number of keycodes that are to be
  14572.           changed.
  14573.  
  14574. The XChangeKeyboardMapping function, starting with
  14575. first_keycode, defines the symbols for the specified number
  14576. of keycodes.  The symbols for keycodes outside this range
  14577. remained unchanged. The number of elements in the keysyms
  14578. list must be a multiple of keysyms_per_keycode.  Otherwise,
  14579. a BadLength error is generated. The specified first_keycode
  14580. must be greater than or equal to min_keycode supplied at
  14581. connection setup and stored in the Display structure.  Oth-
  14582. erwise, a BadValue error is generated.  In addition, the
  14583. following expression must be less than or equal to
  14584. max_keycode as returned in the connection setup (else a Bad-
  14585. Value error).
  14586.  
  14587.  
  14588.         first_keycode + (num_codes / keysyms_per_keycode) - 1
  14589.  
  14590. The KeySym number N, counting from zero, for keycode K has
  14591. an index, counting from zero, of the following in keysyms:
  14592.  
  14593.  
  14594.                   (K - first_keycode) * keysyms_per_keycode + N
  14595.  
  14596. The specified keysyms_per_keycode can be chosen arbitrarily
  14597. by the client to be large enough to hold all desired sym-
  14598. bols. A special KeySym value of NoSymbol should be used to
  14599. fill in unused elements for individual keycodes. It is legal
  14600. for NoSymbol to appear in nontrailing positions of the
  14601. effective list for a keycode.  XChangeKeyboardMapping gen-
  14602. erates a MappingNotify event.
  14603.  
  14604.  
  14605.  
  14606.  
  14607.                      December 18, 1987
  14608.  
  14609.  
  14610.  
  14611.  
  14612.  
  14613.                           - 212 -
  14614.  
  14615.  
  14616. There is no requirement that the X server interpret this
  14617. mapping. It is merely stored for reading and writing by
  14618. clients.
  14619.  
  14620. The other event errors that can be generated by XChangeKey-
  14621. boardMapping are BadValue and BadAlloc.
  14622.  
  14623. The next two functions make use of the following data struc-
  14624. ture.
  14625.  
  14626. typedef struct {
  14627.      int max_keypermod;      /* This server's max number of keys per modifier */
  14628.      KeyCode *modifiermap;   /* An 8 by max_keypermod array of the modifiers */
  14629. } XModifierKeymap;
  14630.  
  14631.  
  14632. Use XNewModifierMapping to create one of these structures.
  14633. The definition for this function is:
  14634.  
  14635. XModifierKeymap XNewModifierMapping(max_keys_per_mod)
  14636.         int max_keys_per_mod;
  14637.  
  14638.  
  14639. max_keys_per_modSpecifies the maximum number of keycodes
  14640.           assigned to any of the modifiers in the map.
  14641.  
  14642. The XNewModifierMapping function returns a XModifierKeymap
  14643. structure.
  14644.  
  14645. Use XFreeModifierMapping to destroy one of these structures.
  14646. The definition for this function is:
  14647.  
  14648. XFreeModifierMapping(modmap)
  14649.         XModifierMapping *modmap;
  14650.  
  14651.  
  14652. modmap    Specifies a pointer to the XModifierKeymap struc-
  14653.           ture.
  14654.  
  14655. The XFreeModifierMapping function frees the specified XModi-
  14656. fierKeymap structure.
  14657.  
  14658.  
  14659. Use XSetModifierMapping to set which keycodes are to be used
  14660. as modifiers. The definition for this function is:
  14661.  
  14662. int XSetModifierMapping(display, modmap)
  14663.         Display *display;
  14664.         XModifierKeymap *modmap;
  14665.  
  14666.  
  14667. display   Specifies the connection to the X server.
  14668.  
  14669.  
  14670.  
  14671.  
  14672.  
  14673.                      December 18, 1987
  14674.  
  14675.  
  14676.  
  14677.  
  14678.  
  14679.                           - 213 -
  14680.  
  14681.  
  14682. modmap    Specifies a pointer to the XModifierKeymap struc-
  14683.           ture.
  14684.  
  14685. The XSetModifierMapping function specifies the keycodes of
  14686. the keys, if any, that are to be used as modifiers.  A zero
  14687. value means that no key should be used. No two arguments can
  14688. have the same nonzero keycode value. Otherwise, a BadValue
  14689. error is generated.
  14690.  
  14691. There are eight modifiers, and the modifiermap member of the
  14692. XModifierKeymap structure contains eight sets of
  14693. max_keypermod keycodes, one for each modifier in the order
  14694. Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5.
  14695. Only nonzero keycodes have meaning in each set, and nonzero
  14696. keycodes are ignored.  In addition, all of the nonzero key-
  14697. codes must be in the range specified by min_keycode and
  14698. max_keycode in the Display structure.  Otherwise, a BadValue
  14699. error is generated.  No keycode may appear twice in the
  14700. entire map. Otherwise, a BadValue error is generated.
  14701.  
  14702. A X server can impose restrictions on how modifiers can be
  14703. changed, for example, if certain keys do not generate up
  14704. transitions in hardware or if multiple modifier keys are not
  14705. supported. If some such restriction is violated, the status
  14706. reply is MappingFailed, and none of the modifiers are
  14707. changed.  If the new keycodes specified for a modifier
  14708. differ from those currently defined and any (current or new)
  14709. keys for that modifier are in the down state, the status
  14710. reply is MappingBusy, and none of the modifiers are changed.
  14711. XSetModifierMapping generates a MappingNotify event on a
  14712. MappingSuccess status.
  14713.  
  14714. The other event errors that can be generated by XSetModifi-
  14715. erMapping are BadAlloc and BadValue.
  14716.  
  14717.  
  14718. Use XGetModifierMapping to obtain the keycodes that are to
  14719. be used as modifiers. The definition for this function is:
  14720.  
  14721. XModifierKeymap *XGetModifierMapping(display)
  14722.       Display *display;
  14723.  
  14724.  
  14725.  
  14726. display   Specifies the connection to the X server.
  14727.  
  14728. The XGetModifierMapping function returns a newly created
  14729. XModifierKeymap structure that contains the keys being used
  14730. as modifiers.  The structure should be freed after use with
  14731. XFreeModifierMapping.  If only zero values appear in the set
  14732. for any modifier,  that modifier is disabled.
  14733.  
  14734.  
  14735.  
  14736.  
  14737.  
  14738.  
  14739.                      December 18, 1987
  14740.  
  14741.  
  14742.  
  14743.  
  14744.  
  14745.                           - 214 -
  14746.  
  14747.  
  14748. 7.10.  Manipulating the Screen Saver
  14749.  
  14750. Xlib provides functions with which you can set, force,
  14751. activate, or reset the screen saver as well as obtain the
  14752. current screen saver values.
  14753.  
  14754.  
  14755. Use XSetScreenSaver to set the screen saver. The definition
  14756. for this function is:
  14757.  
  14758. XSetScreenSaver(display, timeout, interval, prefer_blanking, allow_exposures)
  14759.       Display *display;
  14760.       int timeout, interval;
  14761.       int prefer_blanking;
  14762.       int allow_exposures;
  14763.  
  14764.  
  14765. display   Specifies the connection to the X server.
  14766.  
  14767. timeout   Specifies the timeout, in seconds, until the
  14768.           screen saver turns on.
  14769.  
  14770. interval  Specifies the interval between screen saver invo-
  14771.           cations.
  14772.  
  14773. prefer_blankingSpecifies whether to enable screen blanking.
  14774.           Possible values are DontPreferBlanking, Prefer-
  14775.           Blanking, or DefaultBlanking.
  14776.  
  14777. allow_exposuresSpecifies the current screen save control
  14778.           values.  Possible values are DontAllowExposures,
  14779.           AllowExposures, or DefaultExposures.
  14780.  
  14781. Timeout and interval are specified in seconds. A timeout of
  14782. 0 disables the screen saver, while a timeout of -1 restores
  14783. the default.  Other negative values generate a BadValue
  14784. error.  If the timeout value is nonzero, the function
  14785. enables the screen saver.  An interval of 0 disables the
  14786. random pattern motion.  If no input from devices (keyboard,
  14787. mouse, and so on) is generated once the screen saver is
  14788. enabled, for the specified number of timeout seconds, the
  14789. screen saver is activated.
  14790.  
  14791. For each screen, if blanking is preferred and the hardware
  14792. supports video blanking, the screen will simply go blank.
  14793. Otherwise, if either exposures are allowed or the screen can
  14794. be regenerated without sending exposure events to clients,
  14795. the screen is tiled with the root window background tile at
  14796. randomly re-origined each interval minutes.  Otherwise, the
  14797. state of the screens do not change, and the screen saver is
  14798. not activated.  The screen saver is deactivated and all
  14799. screen states are restored at the next keyboard or pointer
  14800. input or at the next call to XForceScreenSaver with mode
  14801. ScreenSaverReset.
  14802.  
  14803.  
  14804.  
  14805.                      December 18, 1987
  14806.  
  14807.  
  14808.  
  14809.  
  14810.  
  14811.                           - 215 -
  14812.  
  14813.  
  14814. If the server-dependent screen saver method supports
  14815. periodic change, the interval argument serves as a hint
  14816. about how long the change period should be, and zero hints
  14817. that no periodic change should be made.  Examples of ways to
  14818. change the screen include scrambling the color map periodi-
  14819. cally, moving an icon image about the screen periodically,
  14820. or tiling the screen with the root window background tile,
  14821. randomly reoriginated periodically.
  14822.  
  14823. The other error that can be generated by XSetScreenSaver is
  14824. BadValue.
  14825.  
  14826.  
  14827. Use XForceScreenSaver to force the screen saver. The defini-
  14828. tion for this function is:
  14829.  
  14830. XForceScreenSaver(display, mode)
  14831.       Display *display;
  14832.       int mode;
  14833.  
  14834.  
  14835. display   Specifies the connection to the X server.
  14836.  
  14837. mode      Specifies the mode that is to be applied.  XFor-
  14838.           ceScreenSaver applies the specified mode to the
  14839.           screen saver.  The possible modes are Screen-
  14840.           SaverActive or ScreenSaverReset.
  14841.  
  14842. If the specified mode is ScreenSaverActive and the screen
  14843. saver currently is deactivated, the screen saver is
  14844. activated, even if the screen saver had been disabled with a
  14845. timeout of zero (0).  If the specified mode is ScreenSaver-
  14846. Reset and the screen saver currently is enabled, the screen
  14847. saver is deactivated (if it was activated), and the activa-
  14848. tion timer is reset to its initial state (as if device input
  14849. had been received).
  14850.  
  14851. The error that can be generated by XForceScreenSaver is Bad-
  14852. Value.
  14853.  
  14854.  
  14855. Use XActivateScreenSaver to activate the screen saver. The
  14856. definition for this function is:
  14857.  
  14858. XActivateScreenSaver(display)
  14859.       Display *display;
  14860.  
  14861.  
  14862. display   Specifies the connection to the X server.
  14863.  
  14864.  
  14865. Use XResetScreenSaver to reset the screen saver. The defini-
  14866. tion for this function is:
  14867.  
  14868.  
  14869.  
  14870.  
  14871.                      December 18, 1987
  14872.  
  14873.  
  14874.  
  14875.  
  14876.  
  14877.                           - 216 -
  14878.  
  14879.  
  14880. XResetScreenSaver(display)
  14881.       Display *display;
  14882.  
  14883.  
  14884. display   Specifies the connection to the X server.
  14885.  
  14886.  
  14887. Use XGetScreenSaver to get the current screen saver values.
  14888. The definition for this function is:
  14889.  
  14890. XGetScreenSaver(display, timeout_return, interval_return, prefer_blanking_return,
  14891.                   allow_exposures_return)
  14892.       Display *display;
  14893.       int *timeout_return, *interval_return;
  14894.       int *prefer_blanking_return;
  14895.       int *allow_exposures_return;
  14896.  
  14897.  
  14898. display   Specifies the connection to the X server.
  14899.  
  14900. timeout_returnReturns the timeout, in minutes, until the
  14901.           screen saver turns on.
  14902.  
  14903. interval_returnReturns the interval between screen saver
  14904.           invocations.
  14905.  
  14906. prefer_blanking_returnReturns the current screen blanking
  14907.           preference:  DontPreferBlanking, PreferBlanking,
  14908.           or DefaultBlanking.
  14909.  
  14910. allow_exposures_returnReturns the current screen save con-
  14911.           trol value:  DontAllowExposures, AllowExposures,
  14912.           or DefaultExposures.
  14913.  
  14914. 7.11.  Controlling Host Access
  14915.  
  14916. Xlib provides functions with which you can control host
  14917. access.  This section discusses how to:
  14918.  
  14919. o    Add, get, or remove hosts from the access control list
  14920.  
  14921. o    Change, enable, or disable access
  14922.  
  14923. X does not provide any protection on a per-window basis.  If
  14924. you find out the resource ID of a resource, you can manipu-
  14925. late it.  To provide some minimal level of protection, how-
  14926. ever, connections are only permitted from machines you
  14927. trust.  This is adequate on single user workstations, but
  14928. obviously breaks down on timesharing machines.  While provi-
  14929. sions exist in the X protocol for proper connection authen-
  14930. tication, the lack of a standard authentication server
  14931. leaves us with only host level access control.  Currently,
  14932. you can use both DECnet and TCP domains.
  14933.  
  14934.  
  14935.  
  14936.  
  14937.                      December 18, 1987
  14938.  
  14939.  
  14940.  
  14941.  
  14942.  
  14943.                           - 217 -
  14944.  
  14945.  
  14946. The initial set of hosts allowed to open connections con-
  14947. sists of:
  14948.  
  14949. o    The host the window system is running on.
  14950.  
  14951. o    On UNIX-based systems, each host is listed in the
  14952.      /etc/X?.hosts file.  The `?' indicates the number of
  14953.      the display.  This file should consist of host names
  14954.      separated by newlines.  DECnet nodes must terminate in
  14955.      ``::'' to distinguish them from internet hosts.
  14956.  
  14957. If a host is not in the access control list when the access
  14958. control mechanism is enabled and if the host attempts to
  14959. establish a connection, the server refuses the connection
  14960. list or to change the access list.  The client must reside
  14961. on the same host as the server and/or must have been granted
  14962. permission in the initial authorization at connection setup.
  14963. The initial access control list can be specified by provid-
  14964. ing a file that the server can read at startup and reset
  14965. time.
  14966.  
  14967.                             Note
  14968.  
  14969.      Servers also can implement other access control
  14970.      policies in addition to or in place of this hosts
  14971.      access facility.  The name and format of the
  14972.      information in this file is operating system
  14973.      specific.  For further information about other
  14974.      access control implementations, see X Window Sys-
  14975.      tem Protocol, Version 11.
  14976.  
  14977.  
  14978. 7.11.1.  Adding, Getting, or Removing Hosts
  14979.  
  14980. Xlib provides functions with which you can add, get, or
  14981. remove hosts.  All the host access control functions use the
  14982. XHostAddress structure.  The elements in this structure are:
  14983.  
  14984. typedef struct {
  14985.      int family;              /* for example AF_DNET */
  14986.      int length;              /* length of address, in bytes */
  14987.      char *address;           /* pointer to where to find the bytes */
  14988. } XHostAddress;
  14989.  
  14990.  
  14991. family    Specifies which protocol address family to use
  14992.           (for example, TCP/IP or DECnet).  The family sym-
  14993.           bols are defined in <X11/X.h>.
  14994.  
  14995. length    Specifies the length of the address in bytes.
  14996.  
  14997. address   Specifies a pointer to the address.
  14998.  
  14999.  
  15000.  
  15001.  
  15002.  
  15003.                      December 18, 1987
  15004.  
  15005.  
  15006.  
  15007.  
  15008.  
  15009.                           - 218 -
  15010.  
  15011.  
  15012. Use XAddHost to add a single host. The definition for this
  15013. function is:
  15014.  
  15015. XAddHost(display, host)
  15016.       Display *display;
  15017.       XHostAddress *host;
  15018.  
  15019.  
  15020. display   Specifies the connection to the X server.
  15021.  
  15022. host      Specifies the network address of the host machine.
  15023.  
  15024. The XAddHost function adds the specified host to the access
  15025. control list for that display.  The display hardware must be
  15026. on the same host as the program issuing the command.
  15027.  
  15028. The errors that can be generated by XAddHost are BadAlloc
  15029. and BadValue.
  15030.  
  15031.  
  15032. Use XAddHosts to add multiple hosts at one time. The defini-
  15033. tion for this function is:
  15034.  
  15035. XAddHosts(display, hosts, num_hosts)
  15036.       Display *display;
  15037.       XHostAddress *hosts;
  15038.       int num_hosts;
  15039.  
  15040.  
  15041. display   Specifies the connection to the X server.
  15042.  
  15043. hosts     Specifies each host that is to be added.
  15044.  
  15045. num_hosts Specifies the number of hosts.
  15046.  
  15047. The XAddHosts function adds each specified host to the
  15048. access control list for that display.  The display hardware
  15049. must be on the same host as the program issuing the command.
  15050.  
  15051. The errors that can be generated by XAddHosts are BadAlloc
  15052. and BadValue.
  15053.  
  15054.  
  15055. Use XListHosts to obtain a host list. The definition for
  15056. this function is:
  15057.  
  15058. XHostAddress *XListHosts(display, nhosts_return, state_return)
  15059.       Display *display;
  15060.       int *nhosts_return;
  15061.       Bool *state_return;
  15062.  
  15063.  
  15064.  
  15065.  
  15066.  
  15067.  
  15068.  
  15069.                      December 18, 1987
  15070.  
  15071.  
  15072.  
  15073.  
  15074.  
  15075.                           - 219 -
  15076.  
  15077.  
  15078. display   Specifies the connection to the X server.
  15079.  
  15080. nhosts_returnReturns the number of hosts currently in the
  15081.           access control list.
  15082.  
  15083. state_returnReturns the state of the access control (enabled
  15084.           or disabled).
  15085.  
  15086. The XListHosts function returns the current access control
  15087. list as well as whether the use of the list at connection
  15088. setup was enabled or disabled.  XListHosts allows a program
  15089. to find out what machines can make connections.  It also
  15090. returns a pointer to a list of host structures that were
  15091. allocated by the routine. When it no longer is needed, this
  15092. memory should be freed by calling XFree.  (See Section 2.4
  15093. for further information.)
  15094.  
  15095.  
  15096. Use XRemoveHost to remove a single host. The definition for
  15097. this function is:
  15098.  
  15099. XRemoveHost(display, host)
  15100.       Display *display;
  15101.       XHostAddress *host;
  15102.  
  15103.  
  15104. display   Specifies the connection to the X server.
  15105.  
  15106. host      Specifies the network address of the host machine.
  15107.  
  15108. The XRemoveHost function removes the specified host from the
  15109. access control list for that display.  The display hardware
  15110. must be on the same host as the client process.  If you
  15111. remove your machine from the access list, you can no longer
  15112. connect to that server, and this operation cannot be
  15113. reversed short of resetting the server.
  15114.  
  15115. The errors that can be generated by XRemoveHost are BadAlloc
  15116. and BadValue.
  15117.  
  15118.  
  15119. Use XRemoveHosts to remove multiple hosts at one time. The
  15120. definition for this function is:
  15121.  
  15122. XRemoveHosts(display, hosts, num_hosts)
  15123.       Display *display;
  15124.       XHostAddress *hosts;
  15125.       int num_hosts;
  15126.  
  15127.  
  15128. display   Specifies the connection to the X server.
  15129.  
  15130.  
  15131.  
  15132.  
  15133.  
  15134.  
  15135.                      December 18, 1987
  15136.  
  15137.  
  15138.  
  15139.  
  15140.  
  15141.                           - 220 -
  15142.  
  15143.  
  15144. hosts     Specifies each host that is to be added.
  15145.  
  15146. num_hosts Specifies the number of hosts.
  15147.  
  15148. The XRemoveHosts function removes each specified host from
  15149. the access control list for that display.  The display
  15150. hardware must be on the same host as the client process.
  15151. The XRemoveHosts function removes each specified host from
  15152. the access control list for that display. The display
  15153. hardware must be on the same host as the client process.  If
  15154. you remove your machine from the access list, you can no
  15155. longer connect to that server, and this operation cannot be
  15156. reversed short of resetting the server.
  15157.  
  15158. The errors that can be generated by XRemoveHosts are BadAl-
  15159. loc and BadValue.
  15160.  
  15161. 7.11.2.  Changing, Enabling, or Disabling Access Control
  15162.  
  15163. Xlib provides functions with which you can enable, disable,
  15164. or change access control.
  15165.  
  15166. For these functions to execute successfully, the client
  15167. application must reside on the same host as the X server,
  15168. and/or have been given permission in the initial authoriza-
  15169. tion at connection setup.
  15170.  
  15171.  
  15172. Use XSetAccessControl to change access control. The defini-
  15173. tion for this function is:
  15174.  
  15175. XSetAccessControl(display, mode)
  15176.       Display *display;
  15177.       int mode;
  15178.  
  15179.  
  15180. display   Specifies the connection to the X server.
  15181.  
  15182. mode      Specifies whether you want to change the access
  15183.           control to enable or disable.  EnableAccess
  15184.           enables host access control or DisableAccess dis-
  15185.           ables host access control.
  15186.  
  15187. The XSetAccessControl function either enables or disables
  15188. the use of the access control list at connection setups.
  15189.  
  15190. The errors that can be generated by XSetAccessControl are
  15191. BadAlloc and BadAccess.
  15192.  
  15193.  
  15194. Use XEnableAccessControl to enable access control. The
  15195. definition for this function is:
  15196.  
  15197.  
  15198.  
  15199.  
  15200.  
  15201.                      December 18, 1987
  15202.  
  15203.  
  15204.  
  15205.  
  15206.  
  15207.                           - 221 -
  15208.  
  15209.  
  15210. XEnableAccessControl(display)
  15211.       Display *display;
  15212.  
  15213.  
  15214. display   Specifies the connection to the X server.
  15215.  
  15216. The XEnableAccessControl function enables the use of the
  15217. access control list at connection setups.
  15218.  
  15219. The error that can be generated by XEnableAccessControl is
  15220. BadAccess.
  15221.  
  15222.  
  15223. Use XDisableAccessControl to disable access control. The
  15224. definition for this function is:
  15225.  
  15226. XDisableAccessControl(display)
  15227.       Display *display;
  15228.  
  15229.  
  15230. display   Specifies the connection to the X server.
  15231.  
  15232. The XDisableAccessControl function disables the use of the
  15233. access control list at connection setups.
  15234.  
  15235. The error that can be generated by XDisableAccessControl is
  15236. BadAccess.
  15237.  
  15238.  
  15239.  
  15240.  
  15241.  
  15242.  
  15243.  
  15244.  
  15245.  
  15246.  
  15247.  
  15248.  
  15249.  
  15250.  
  15251.  
  15252.  
  15253.  
  15254.  
  15255.  
  15256.  
  15257.  
  15258.  
  15259.  
  15260.  
  15261.  
  15262.  
  15263.  
  15264.  
  15265.  
  15266.  
  15267.                      December 18, 1987
  15268.  
  15269.  
  15270.  
  15271.  
  15272.  
  15273.                           - 222 -
  15274.  
  15275.  
  15276.  
  15277.  
  15278.                          Chapter 8
  15279.  
  15280.             Events and Event-Handling Functions
  15281.  
  15282.  
  15283.  
  15284. Chapter 8 - Events and Event-Handling Functions A client
  15285. application communicates with the X server through the con-
  15286. nection you establish with the XOpenDisplay function.  It is
  15287. over this connection that a client application sends
  15288. ``requests'' to the X server.  These requests are made by
  15289. the Xlib functions that are called in the client applica-
  15290. tion.  The X server sends back to the client application
  15291. either ``replies'' or events.  Most requests made by Xlib
  15292. functions do not generate replies.  Some requests generate
  15293. multiple replies.  Numerous Xlib functions cause the X
  15294. server to generate events.  In addition, the user's typing
  15295. or moving the pointer can generate events asynchronously.
  15296.  
  15297. This chapter begins with a discussion of the following
  15298. topics associated with events:
  15299.  
  15300. o    Event types
  15301.  
  15302. o    Event structures
  15303.  
  15304. o    Event mask
  15305.  
  15306. o    Event processing
  15307.  
  15308. The chapter continues with a discussion of the Xlib func-
  15309. tions you can use to:
  15310.  
  15311. o    Select events
  15312.  
  15313. o    Handle the output buffer and the event queue
  15314.  
  15315. o    Select events from the event queue
  15316.  
  15317. o    Send and get events
  15318.  
  15319. o    Handle error events
  15320.  
  15321.                             Note
  15322.  
  15323.      Some toolkits use their own event-handling rou-
  15324.      tines.  Also, some toolkits do not allow you to
  15325.      interchange these event-handling routines with
  15326.      those in the Xlib library.  See the document sup-
  15327.      plied with your toolkit for further information.
  15328.  
  15329.  
  15330.  
  15331.  
  15332.  
  15333.                      December 18, 1987
  15334.  
  15335.  
  15336.  
  15337.  
  15338.  
  15339.                           - 223 -
  15340.  
  15341.  
  15342. Most applications simply are event loops.  That is, they
  15343. wait for an event, decide what to do with it, execute some
  15344. amount of code, which, in turn, results in changes to the
  15345. display, and then wait for the next event.
  15346.  
  15347. 8.1.  Event Types
  15348.  
  15349. An event is data generated asynchronously by the X server as
  15350. a result of some device activity, or as side effects of a
  15351. request sent by an Xlib function.  Device-related events
  15352. propagate from the source window to ancestor windows until
  15353. some client application has selected that event type, or
  15354. until the event is explicitly discarded.  The X server never
  15355. sends an event to a client application, unless the client
  15356. has specifically asked to be informed of that event type,
  15357. usually by calling the Xlib function XSelectInput.  The mask
  15358. can also be set when you create a window or by changing the
  15359. window's event_mask.  You can also mask out events that
  15360. would propagate to outer windows by manipulating the
  15361. do_not_propagate mask of the window's attributes.
  15362.  
  15363. The event type describes a specific event generated by the X
  15364. server.  For each event type, there is a corresponding con-
  15365. stant name defined in <X11/X.h>.  When referring to an event
  15366. type, this manual uses the constant name defined in this
  15367. file.  It is often useful to group one or more event types
  15368. into logical categories.  For example, exposure processing
  15369. refers to the processing that occurs for the exposure events
  15370. Expose, GraphicsExpose, and NoExpose.
  15371.  
  15372. The following table lists the event category and its associ-
  15373. ated event type or types. The processing associated with
  15374. these events is discussed in Section 8.4.
  15375.  
  15376.  
  15377.  
  15378. _________________________________________________________________
  15379. Event Category                Event Type
  15380. _________________________________________________________________
  15381. Keyboard events
  15382.                               KeyPress, KeyRelease
  15383.  
  15384. Pointer motion events
  15385.                               ButtonPress, ButtonRelease, Motion-
  15386.                               Notify
  15387.  
  15388.  
  15389. Window crossing events
  15390.                               EnterNotify, LeaveNotify
  15391.  
  15392. Input focus events
  15393.                               FocusIn, FocusOut
  15394. Key map state notification
  15395. event
  15396.                               KeymapNotify
  15397.  
  15398. Exposure events               Expose, GraphicsExpose, NoExpose
  15399. Structure control events
  15400.                               CirculateRequest, ConfigureRequest,
  15401.                               MapRequest, ResizeRequest
  15402.  
  15403.  
  15404. Window state notification
  15405.  
  15406.  
  15407.  
  15408.                      December 18, 1987
  15409.  
  15410.  
  15411.  
  15412.  
  15413.  
  15414.                           - 224 -
  15415.  
  15416.  
  15417. _________________________________________________________________
  15418. Event Category                Event Type
  15419. _________________________________________________________________
  15420. events
  15421.  
  15422.  
  15423.  
  15424.  
  15425.  
  15426.  
  15427.  
  15428.  
  15429.  
  15430.  
  15431.  
  15432.  
  15433.  
  15434.  
  15435.  
  15436.  
  15437.  
  15438.  
  15439.  
  15440.  
  15441.  
  15442.  
  15443.  
  15444.  
  15445.  
  15446.  
  15447.  
  15448.  
  15449.  
  15450.  
  15451.  
  15452.  
  15453.  
  15454.  
  15455.  
  15456.  
  15457.  
  15458.  
  15459.  
  15460.  
  15461.  
  15462.  
  15463.  
  15464.  
  15465.  
  15466.  
  15467.  
  15468.  
  15469.                               CirculateNotify, ConfigureNotify,
  15470.  
  15471.  
  15472.  
  15473.                      December 18, 1987
  15474.  
  15475.  
  15476.  
  15477.  
  15478.  
  15479.                           - 225 -
  15480.  
  15481.  
  15482. _________________________________________________________________
  15483. Event Category                Event Type
  15484. _________________________________________________________________
  15485.                               CreateNotify, DestroyNotify, Gravi-
  15486.                               tyNotify, MapNotify, MappingNotify,
  15487.                               ReparentNotify, UnmapNotify, Visi-
  15488.                               bilityNotify
  15489.  
  15490.  
  15491.  
  15492.  
  15493.  
  15494.  
  15495.  
  15496.  
  15497.  
  15498.  
  15499.  
  15500.  
  15501.  
  15502.  
  15503.  
  15504.  
  15505.  
  15506.  
  15507.  
  15508.  
  15509.  
  15510.  
  15511.  
  15512.  
  15513.  
  15514.  
  15515.  
  15516.  
  15517.  
  15518.  
  15519.  
  15520.  
  15521.  
  15522.  
  15523.  
  15524.  
  15525.  
  15526.  
  15527.  
  15528.  
  15529.  
  15530.  
  15531.  
  15532.  
  15533.  
  15534.  
  15535.  
  15536.  
  15537.  
  15538.                      December 18, 1987
  15539.  
  15540.  
  15541.  
  15542.  
  15543.  
  15544.                           - 226 -
  15545.  
  15546.  
  15547. _________________________________________________________________
  15548. Event Category                Event Type
  15549. _________________________________________________________________
  15550.  
  15551.  
  15552.  
  15553.  
  15554.  
  15555.  
  15556.  
  15557.  
  15558.  
  15559.  
  15560.  
  15561.  
  15562.  
  15563.  
  15564.  
  15565.  
  15566.  
  15567.  
  15568.  
  15569.  
  15570.  
  15571.  
  15572.  
  15573.  
  15574.  
  15575.  
  15576.  
  15577.  
  15578.  
  15579.  
  15580.  
  15581.  
  15582.  
  15583.  
  15584.  
  15585.  
  15586.  
  15587.  
  15588.  
  15589.  
  15590.  
  15591.  
  15592.  
  15593.  
  15594.  
  15595.  
  15596.  
  15597.  
  15598.  
  15599.  
  15600.  
  15601.  
  15602.  
  15603.                      December 18, 1987
  15604.  
  15605.  
  15606.  
  15607.  
  15608.  
  15609.                           - 227 -
  15610.  
  15611.  
  15612. _________________________________________________________________
  15613. Event Category                Event Type
  15614. _________________________________________________________________
  15615. Color map state notifica-
  15616. tion event
  15617.                               ColormapNotify
  15618.  
  15619.                               ClientMessage, PropertyNotify,
  15620.                               SelectionClear, SelectionNotify,
  15621.                               SelectionRequest
  15622. Client communication events
  15623.  
  15624.  
  15625. _________________________________________________________________
  15626.  
  15627.  
  15628. 8.2.  Event Structures
  15629.  
  15630. Each event type has a corresponding structure declared in
  15631. <X11/Xlib.h>.  All event structures have a member called
  15632. type, which the X server sets to the event type constant
  15633. name that uniquely identifies it. For example, when the X
  15634. server reports a GraphicsExpose event to a client applica-
  15635. tion, it sends an XGraphicsExposeEvent structure with the
  15636. type member set to the constant GraphicsExpose.  Each event
  15637. structure also has a display member, which Xlib sets to a
  15638. pointer to the display the event was read on.
  15639.  
  15640. The X server may send events at any time in the input
  15641. stream, even between the time your client application sends
  15642. a request and receives a reply.  Xlib stores in an event
  15643. queue any events received while waiting for a reply for
  15644. later use.  Xlib also provides several functions that allow
  15645. you to check events in the event queue, and these are dis-
  15646. cussed in Section 8.6.
  15647.  
  15648. In addition to the individual structures declared for each
  15649. event type, there is also a generic XEvent structure. The
  15650. XEvent structure is a union of the individual structures
  15651. declared for each event type.  Once you determine the event
  15652. type, use the structures declared in <X11/Xlib.h> when mak-
  15653. ing references to it in a client application.  All events
  15654. contain a ``type'' member that determines the format of the
  15655. information.  Depending on the type, you should access ele-
  15656. ments of each event by using the XEvent union.
  15657.  
  15658. 8.3.  Event Mask
  15659.  
  15660. Clients select event reporting of most events relative to a
  15661. window.  To do this, you pass an event mask to an Xlib
  15662. event-handling function that takes an event_mask argument.
  15663. The bits of the event mask are defined in <X11/X.h>.  Each
  15664. bit in the event mask maps to an event mask name.  The event
  15665. mask name describes the event or events you want the X
  15666. server to return to a client application.  When referring to
  15667. a specific event mask, this manual uses the constant name
  15668. defined in this file.
  15669.  
  15670.  
  15671.  
  15672.                      December 18, 1987
  15673.  
  15674.  
  15675.  
  15676.  
  15677.  
  15678.                           - 228 -
  15679.  
  15680.  
  15681. Most events are not reported to clients when they are gen-
  15682. erated, unless the client has specifically asked for them.
  15683. GraphicsExpose and NoExpose, however, are reported, by
  15684. default, as a result of XCopyPlane and XCopyArea, unless the
  15685. client suppresses them by setting graphics_expose in the GC
  15686. to False.  See Section 6.2 for further information.  Selec-
  15687. tionClear, SelectionRequest, SelectionNotify or ClientMes-
  15688. sage cannot be masked, but they generally are only sent to
  15689. clients cooperating with selections.  See Section 4.4 for
  15690. further information.  MappingNotify is always sent to
  15691. clients when the keyboard mapping is changed.
  15692.  
  15693. The following table lists the event mask constants you can
  15694. pass to the event_mask argument and the circumstances in
  15695. which you would want to specify the event mask.
  15696.  
  15697.  
  15698. ________________________________________________________________
  15699. Event Mask                 Circumstances
  15700. ________________________________________________________________
  15701. NoEventMask                No events wanted
  15702. KeyPressMask               Keyboard down events wanted
  15703. KeyReleaseMask             Keyboard up events wanted
  15704. ButtonPressMask            Pointer button down events wanted
  15705. ButtonReleaseMask          Pointer button up events wanted
  15706. EnterWindowMask            Pointer window entry events wanted
  15707. LeaveWindowMask            Pointer window leave events wanted
  15708. PointerMotionMask          Pointer motion events wanted
  15709. PointerMotionHintMask      Pointer motion hints wanted
  15710. Button1MotionMask          Pointer motion while button 1 down
  15711. Button2MotionMask          Pointer motion while button 2 down
  15712. Button3MotionMask          Pointer motion while button 3 down
  15713. Button4MotionMask          Pointer motion while button 4 down
  15714. Button5MotionMask          Pointer motion while button 5 down
  15715. ButtonMotionMask           Pointer motion while any button down
  15716. KeymapStateMask            Any keyboard state change wanted
  15717. ExposureMask               Any exposure wanted
  15718. VisibilityChangeMask       Any change in visibility wanted
  15719. StructureNotifyMask        Any change in window structure wanted
  15720. ResizeRedirectMask         Redirect resize of this window
  15721. SubstructureNotifyMask     Substructure notification wanted
  15722. SubstructureRedirectMask   Redirect substructure of window
  15723. FocusChangeMask            Any change in input focus wanted
  15724. PropertyChangeMask         Any change in property wanted
  15725. ColormapChangeMask         Any change in Colormap wanted
  15726. OwnerGrabButtonMask        Automatic grabs should activate
  15727.                            when owner_events is True
  15728. ________________________________________________________________
  15729.  
  15730.  
  15731.  
  15732.  
  15733.  
  15734.  
  15735.  
  15736.  
  15737.                      December 18, 1987
  15738.  
  15739.  
  15740.  
  15741.  
  15742.  
  15743.                           - 229 -
  15744.  
  15745.  
  15746. 8.4.  Event Processing
  15747.  
  15748. The event types reported to a client application during
  15749. event processing depend on which event masks you pass to the
  15750. event_mask argument of the XSelectInput function (Section
  15751. 8.5).  For some event masks, there is a one-to-one
  15752. correspondence between the event mask constant and the event
  15753. type constant.  For example, if you pass the event mask But-
  15754. tonPressMask, the X server sends back only ButtonPress
  15755. events.  Most events contain a time member that is the time
  15756. at which an event occurred.
  15757.  
  15758. In other cases, one event mask constant can map to several
  15759. event type constants.  For example, if you pass the event
  15760. mask SubstructureNotifyMask, the X server can send back Cir-
  15761. culateNotify, ConfigureNotify, CreateNotify, DestroyNotify,
  15762. GravityNotify, MapNotify, ReparentNotify, or UnmapNotify
  15763. events.
  15764.  
  15765. In another case, two event mask constants map to one event
  15766. type constant.  For example, if you pass the event mask
  15767. PointerMotionMask or PointerMotionHintMask the X server
  15768. sends back a MotionNotify event.
  15769.  
  15770. The following table lists the event mask, its associated
  15771. event type or types, and the structure name associated with
  15772. the event type.  Note that the letters N.A. appear in
  15773. columns for which the information is not applicable.
  15774.  
  15775.  
  15776. _____________________________________________________________________
  15777. Event Mask                 Event Type          Structure
  15778. _____________________________________________________________________
  15779. ButtonMotionMask           MotionNotify        XPointerMovedEvent
  15780. Button1MotionMask
  15781. Button2MotionMask
  15782. Button3MotionMask
  15783. Button4MotionMask
  15784. Button5MotionMask
  15785. ButtonPressMask            ButtonPress         XButtonPressedEvent
  15786. ButtonReleaseMask          ButtonRelease       XButtonReleasedEvent
  15787. ColormapChangeMask         ColormapNotify      XColormapEvent
  15788. EnterWindowMask            EnterNotify         XEnterWindowEvent
  15789. ExposureMask               Expose              XExposeEvent
  15790.                            GraphicsExpose      XGraphicsExposeEvent
  15791.                            NoExpose            XNoExposeEvent
  15792. LeaveWindowMask            LeaveNotify         XLeaveWindowEvent
  15793. FocusChangeMask            FocusIn             XFocusInEvent
  15794.                            FocusOut            XFocusOutEvent
  15795. KeymapStateMask            KeymapNotify        XKeymapEvent
  15796.  
  15797.  
  15798.                      December 18, 1987
  15799.  
  15800.  
  15801.  
  15802.  
  15803.  
  15804.                           - 230 -
  15805.  
  15806.  
  15807. _____________________________________________________________________
  15808. Event Mask                 Event Type          Structure
  15809. _____________________________________________________________________
  15810. KeyPressMask               KeyPress            XKeyPressedEvent
  15811.                            KeyRelease          XKeyReleasedEvent
  15812. OwnerGrabButtonMask        N.A.                N.A.
  15813. PointerMotionMask          MotionNotify        XPointerMovedEvent
  15814. PointerMotionHintMask
  15815. PropertyChangeMask         PropertyNotify      XPropertyEvent
  15816. ResizeRedirectMask         ResizeRequest       XResizeRequestEvent
  15817. StructureNotifyMask        CirculateNotify     XCirculateEvent
  15818.                            ConfigureNotify     XConfigureEvent
  15819.                            DestroyNotify       XDestroyWindowEvent
  15820.                            GravityNotify       XGravityEvent
  15821.                            MapNotify           XMapEvent
  15822.                            ReparentNotify      XReparentEvent
  15823.                            UnmapNotify         XUnmapEvent
  15824. SubstructureNotifyMask     CirculateNotify     XCirculateEvent
  15825.                            ConfigureNotify     XConfigureEvent
  15826.                            CreateNotify        XCreateWindowEvent
  15827.                            DestroyNotify       XDestroyWindowEvent
  15828.                            GravityNotify       XGravityEvent
  15829.                            MapNotify           XMapEvent
  15830.                            ReparentNotify      XReparentEvent
  15831.                            UnmapNotify         XUnmapEvent
  15832. SubstructureRedirectMask   CirculateRequest    XCirculateRequestEvent
  15833.                            ConfigureRequest    XConfigureRequestEvent
  15834.                            MapRequest          XMapRequestEvent
  15835. N.A.                       ClientMessage       XClientMessageEvent
  15836. N.A.                       MappingNotify       XMappingEvent
  15837. N.A.                       SelectionClear      XSelectionClearEvent
  15838. N.A.                       SelectionNotify     XSelectionEvent
  15839. N.A.                       SelectionRequest    XSelectionRequestEvent
  15840. VisibilityChangeMask       VisibilityNotify    XVisibilityEvent
  15841. _____________________________________________________________________
  15842.  
  15843.  
  15844. The sections below describe the processing that occurs when
  15845. you pass the different event masks to XSelectInput (Section
  15846. 8.5). The sections are organized according to these process-
  15847. ing categories:
  15848.  
  15849. o    Keyboard and pointer event processing
  15850.  
  15851.  
  15852.  
  15853.  
  15854.  
  15855.  
  15856.                      December 18, 1987
  15857.  
  15858.  
  15859.  
  15860.  
  15861.  
  15862.                           - 231 -
  15863.  
  15864.  
  15865. o    Window crossing event processing
  15866.  
  15867. o    Input focus event processing
  15868.  
  15869. o    Key map state notification event processing
  15870.  
  15871. o    Exposure event processing
  15872.  
  15873. o    Window state notification event processing
  15874.  
  15875. o    Structure control event processing
  15876.  
  15877. o    Color map state notification event processing
  15878.  
  15879. o    Client communication event processing
  15880.  
  15881. The processing descriptions include explanations of the
  15882. structure or structures associated with the event.  All the
  15883. event structures contain the members type and display, which
  15884. were discussed in Section 8.2.  Thus, the explanations for
  15885. these members are not repeated in the following sections.
  15886.  
  15887. 8.4.1.  Keyboard and Pointer Event Processing
  15888.  
  15889. This section discusses the event processing that occurs when
  15890. a pointer button is pressed and when the keyboard events
  15891. KeyPress and KeyRelease and the pointer motion events But-
  15892. tonPress, ButtonRelease, and MotionNotify are generated.
  15893.  
  15894. 8.4.1.1.  Pointer Button Specific Processing
  15895.  
  15896. The following describes the event processing that occurs
  15897. when a pointer button is pressed with the pointer in some
  15898. window w and when no active pointer grab is in progress.
  15899.  
  15900. The X server searches the ancestors of w from the root down,
  15901. looking for a passive grab to activate.  If no matching pas-
  15902. sive grab on the button exists, the X server automatically
  15903. starts an active grab for the client receiving the event and
  15904. sets the last-pointer-grab time to the current server time.
  15905. The effect is essentially equivalent to an XGrabButton with
  15906. these client passed arguments:
  15907.  
  15908. w         The event window
  15909.  
  15910. event_maskThe client's selected pointer motion events on the
  15911.           event window.
  15912.  
  15913. pointer_modeGrabModeAsync.
  15914.  
  15915. keyboard_modeGrabModeAsync.
  15916.  
  15917.  
  15918.  
  15919.  
  15920.  
  15921.  
  15922.                      December 18, 1987
  15923.  
  15924.  
  15925.  
  15926.  
  15927.  
  15928.                           - 232 -
  15929.  
  15930.  
  15931. owner_eventsTrue, if the client has selected OwnerGrabBut-
  15932.           tonMask on the event window; otherwise, False.
  15933.  
  15934. confine_toNone.
  15935.  
  15936. cursor    None.
  15937.  
  15938. The grab is automatically terminated when all buttons are
  15939. released.  Clients can modify the active grab by calling
  15940. XUngrabPointer and XChangeActivePointerGrab.
  15941.  
  15942. 8.4.1.2.  Common Keyboard and Pointer Event Processing
  15943.  
  15944. This section discusses the processing that occurs for the
  15945. keyboard events KeyPress and KeyRelease and the pointer
  15946. motion events ButtonPress, ButtonRelease, and MotionNotify.
  15947. See Chapter 10 for information about the keyboard event han-
  15948. dling utility functions provided in XLib.
  15949.  
  15950. The X server can report KeyPress events to clients wanting
  15951. information about when a key is pressed and KeyRelease
  15952. events to clients wanting information about when a key is
  15953. released.  The X server generates these events whenever a
  15954. key changes state, that is, whenever the key is pressed or
  15955. released.  Note that these events are generated for all
  15956. keys, even those mapped to modifier bits.  The X server
  15957. reports ButtonPress events to clients wanting information
  15958. about when a pointer button is pressed and ButtonRelease
  15959. events to clients wanting information about when a pointer
  15960. button is released.  The X server generates these events
  15961. whenever a pointer button changes state, that is, whenever
  15962. the pointer button is pressed or released.
  15963.  
  15964. The X server reports MotionNotify events to clients wanting
  15965. information about when the pointer moves.  The X server gen-
  15966. erates this event whenever the pointer changes state, that
  15967. is, whenever the pointer is moved and the pointer motion
  15968. begins and ends in the window.  The granularity of MotionNo-
  15969. tify events is not guaranteed, but a client that selects
  15970. this event type is guaranteed to receive at least one event
  15971. when the pointer moves and then rests.
  15972.  
  15973. To receive KeyPress, KeyRelease, ButtonPress, and Button-
  15974. Release events in a client application, you pass a window ID
  15975. and KeyPressMask, KeyReleaseMask, ButtonPressMask, and But-
  15976. tonReleaseMask as the event_mask arguments to XSelectInput.
  15977.  
  15978. To receive MotionNotify events in a client application, you
  15979. pass a window ID and one or more of the following event
  15980. masks as the event_mask argument to XSelectInput:
  15981.  
  15982. o    Button1MotionMask-Button5MotionMask
  15983.  
  15984.  
  15985.  
  15986.  
  15987.  
  15988.                      December 18, 1987
  15989.  
  15990.  
  15991.  
  15992.  
  15993.  
  15994.                           - 233 -
  15995.  
  15996.  
  15997.      The client application receives MotionNotify events
  15998.      only when one or more of the specified buttons is
  15999.      pressed.
  16000.  
  16001. o    ButtonMotionMask
  16002.  
  16003.      The client application receives MotionNotify events
  16004.      only when at least one button is pressed.
  16005.  
  16006. o    PointerMotionMask
  16007.  
  16008.      The client application receives MotionNotify events
  16009.      independent of the state of the pointer buttons.
  16010.  
  16011. o    PointerMotionHint
  16012.  
  16013.      If PointerMotionHintMask is selected, the X server is
  16014.      free to send only one MotionNotify event (with the
  16015.      is_hint member  of the XPointerMovedEvent structure set
  16016.      to NotifyHint) to the client for the event window,
  16017.      until either the key or button state changes, or the
  16018.      pointer leaves the event window, or the client calls
  16019.      the XQueryPointer or XGetMotionEvents functions.
  16020.  
  16021. The source of the event is the smallest window containing
  16022. the pointer.  The window used by the X server to report
  16023. these events depends on its position in the window hierarchy
  16024. and whether any intervening window prohibits the generation
  16025. of these events.  The X server searches up the window
  16026. hierarchy, starting with the source window, until it locates
  16027. the first window specified by a client as having an interest
  16028. in these events.  If one of the intervening windows has its
  16029. do_not_propagate_mask set to prohibit generation of the
  16030. event type, the event of those types will be suppressed.
  16031. Clients can modify the actual window used for reporting by
  16032. performing active grabs, and, in the case of keyboard
  16033. events, by using the focus window.  See Chapter 7 for a dis-
  16034. cussion of the XGrabPointer, XGrabKeyboard, and XSetInput-
  16035. Focus functions.
  16036.  
  16037. The structures associated with these events are
  16038. XKeyPressedEvent, XKeyReleasedEvent, XButtonPressedEvent,
  16039. XButtonReleasedEvent, and XPointerMovedEvent.  The window
  16040. the event is reported with respect to is called the event
  16041. window.  These structures have the following common members:
  16042. window, root, subwindow, time, x, y, x_root, y_root, state,
  16043. and same_screen.
  16044.  
  16045. The window member is set to the window ID of the window on
  16046. which the event was generated and is referred to as the
  16047. event window. This is the window used by the X server to
  16048. report the event, as long as the conditions discussed in the
  16049. previous paragraph are met.  The root member is set to the
  16050. window ID of the source window's root window.  The x_root
  16051.  
  16052.  
  16053.  
  16054.                      December 18, 1987
  16055.  
  16056.  
  16057.  
  16058.  
  16059.  
  16060.                           - 234 -
  16061.  
  16062.  
  16063. and y_root members are set to the pointer's coordinates
  16064. relative to the root window's origin at the time of the
  16065. event.
  16066.  
  16067. The same_screen member is set to indicate whether the event
  16068. window is on the same screen as the root window and can be
  16069. one of the constants True or False.  If True, the event and
  16070. root windows are on the same screen.  If False, the event
  16071. and root windows are not on the same screen.
  16072.  
  16073. If the source window is an inferior of the event window, the
  16074. subwindow member of the structure is set to the child of the
  16075. event window that is an ancestor of or is the source member.
  16076. Otherwise, the X server sets the subwindow member to the
  16077. constant None.  The time member is set to the time when the
  16078. event was generated and is expressed in milliseconds since
  16079. the server reset.
  16080.  
  16081. If the event window is on the same screen as the root win-
  16082. dow, the x and y members are set to the coordinates relative
  16083. to the event window's origin.  Otherwise, these members are
  16084. set to zero.
  16085.  
  16086. The state member is set to indicate the state of the pointer
  16087. buttons and modifier keys just prior to the event.  For the
  16088. state of the pointer buttons, the X server can set this
  16089. member to the bitwise inclusive OR of one or more of the
  16090. button or modifier key masks:  Button1Mask, Button2Mask,
  16091. Button3Mask, Button4Mask, Button5Mask, ShiftMask, LockMask,
  16092. ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask,
  16093. Mod5Mask.
  16094.  
  16095. Each of these structures also has a member that indicates
  16096. the detail.  For the XKeyPressedEvent and XKeyReleasedEvent
  16097. structures, this member is called keycode.  It is set to a
  16098. number that represents a physical key on the keyboard.  The
  16099. keycode is an arbitrary representation for any key on the
  16100. keyboard.  See Chapter 10 for more information on the key-
  16101. code.
  16102.  
  16103. For the XButtonPressedEvent and XButtonReleasedEvent struc-
  16104. tures, this member is called button.  It represents the
  16105. pointer buttons that changed state and can be set to the
  16106. bitwise inclusive OR of one or more of these button names:
  16107. Button1, Button2, Button3, Button4, Button5.  For the XPoin-
  16108. terMovedEvent structure, this member is called is_hint.  It
  16109. can be set to one of these constants: NotifyNormal or
  16110. NotifyHint.
  16111.  
  16112. 8.4.2.  Window Entry/Exit Event Processing
  16113.  
  16114. This section describes the processing that occurs for the
  16115. window crossing events EnterNotify and LeaveNotify.  If a
  16116. pointer motion or a window hierarchy change causes the
  16117.  
  16118.  
  16119.  
  16120.                      December 18, 1987
  16121.  
  16122.  
  16123.  
  16124.  
  16125.  
  16126.                           - 235 -
  16127.  
  16128.  
  16129. pointer to be in a different window than before, the X
  16130. server reports EnterNotify or LeaveNotify events to clients
  16131. who have selected for these events.  All EnterNotify and
  16132. LeaveNotify events caused by a hierarchy change are gen-
  16133. erated after any hierarchy event ( UnmapNotify, MapNotify,
  16134. ConfigureNotify, GravityNotify, CirculateNotify) caused by
  16135. that change, but the ordering of EnterNotifyand LeaveNotify
  16136. events with respect to FocusOut, VisibilityNotify, and
  16137. Expose events is not constrained by the X protocol.
  16138.  
  16139. This contrasts with MotionNotify events, which are also gen-
  16140. erated when the pointer moves, but the pointer motion begins
  16141. and ends in a single window.  An EnterNotify or LeaveNotify
  16142. event may also be generated when some client application
  16143. calls XChangeActivePointerGrab, XGrabKeyboard, XGrabPointer,
  16144. and XUngrabPointer.
  16145.  
  16146. To receive EnterNotify events in a client application, you
  16147. must pass a window ID and EnterWindowMask as the event_mask
  16148. argument to XSelectInput.  Likewise, to receive LeaveNotify
  16149. events, you pass the window ID and LeaveWindowMask.
  16150.  
  16151. The members of the XEnterWindowEvent and XLeaveWindowEvent
  16152. structures associated with these events are window, root,
  16153. subwindow, time, x, y, x_root, y_root, mode, detail,
  16154. same_screen, focus, and state.  The pointer position
  16155. reported in the event is always the final position, not the
  16156. initial position of the pointer.
  16157.  
  16158. The window member is set to the window ID of the window on
  16159. which the EnterNotify or LeaveNotify event was generated and
  16160. is referred to as the event window. This is the window used
  16161. by the X server to report the event, and is relative to the
  16162. root window on which the event occurred. The root member is
  16163. the root window for this position and is set to the window
  16164. ID of the root window on which the event occurred.
  16165.  
  16166. In a LeaveNotify event, if a child of the event window con-
  16167. tains the initial position of the pointer, the subwindow
  16168. component is set to that child.  Otherwise, the X server
  16169. sets the subwindow member to the constant None.  For an
  16170. EnterNotify event, if a child of the event window contains
  16171. the final pointer position, the subwindow component is set
  16172. to that child.  Otherwise, it is set to the constant None.
  16173.  
  16174. The time member is set to the time when the event was gen-
  16175. erated and is expressed in milliseconds.  The x and y
  16176. members are set to the coordinates of the pointer position
  16177. in the event window.  This position is always the final
  16178. position of the pointer, not the initial position of the
  16179. pointer.  If the event window is on the same screen as the
  16180. root window, x and y are the pointer coordinates relative to
  16181. the event window's origin. Otherwise, x and y are set to
  16182. zero.  The x_root and y_root members are set to the
  16183.  
  16184.  
  16185.  
  16186.                      December 18, 1987
  16187.  
  16188.  
  16189.  
  16190.  
  16191.  
  16192.                           - 236 -
  16193.  
  16194.  
  16195. pointer's coordinates relative to the root window's origin
  16196. at the time of the event.
  16197.  
  16198. The same_screen member is set to indicate whether the event
  16199. window is on the same screen as the root window and can be
  16200. one of the constants True or False.  If True, the event and
  16201. root windows are on the same screen.  If False, the event
  16202. and root windows are not on the same screen.
  16203.  
  16204. The focus member is set to indicate whether the event window
  16205. is the focus window or an inferior of the focus window.  The
  16206. X server can set this member to the constants True or False.
  16207. If True, the event window is the focus window or an inferior
  16208. of the focus window.  If False, the event window is not the
  16209. focus window or an inferior of the focus window.
  16210.  
  16211. The state member is set to indicate the state of the pointer
  16212. buttons and modifier keys just prior to the event.  For the
  16213. state of the pointer buttons, the X server can set this
  16214. member to the bitwise inclusive OR of one or more of the
  16215. button or modifier key masks:  Button1Mask, Button2Mask,
  16216. Button3Mask, Button4Mask, Button5Mask, ShiftMask, LockMask,
  16217. ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask,
  16218. Mod5Mask.
  16219.  
  16220. The mode member is set to indicate whether the events are
  16221. normal events, pseudo-motion events when a grab activates,
  16222. or pseudo-motion events when a grab deactivates.  The X
  16223. server can set this member to the corresponding constants
  16224. NotifyNormal, NotifyGrab, or NotifyUngrab.
  16225.  
  16226. The detail member is set to indicate the notify detail and
  16227. can be one of these constants:  NotifyAncestor, NotifyVir-
  16228. tual, NotifyInferior, NotifyNonlinear, or NotifyNonlinear-
  16229. Virtual.
  16230.  
  16231. The following sections discuss how the X server processes
  16232. normal pointer motion events and pseudo motion events.
  16233.  
  16234. 8.4.2.1.  Normal Entry/Exit Event Processing
  16235.  
  16236. EnterNotify and LeaveNotify events are generated when the
  16237. pointer moves from one window to another window.  Normal
  16238. events are identified by XEnterWindowEvent or XLeaveWin-
  16239. dowEvent structures whose mode member is set to the constant
  16240. NotifyNormal.
  16241.  
  16242. o    When the pointer moves from window A to window B, and A
  16243.      is an inferior of B, the X server generates:
  16244.  
  16245.      -    A LeaveNotify event on window A with the detail
  16246.           member of the XLeaveWindowEvent structure set to
  16247.           the constant NotifyAncestor.
  16248.  
  16249.  
  16250.  
  16251.  
  16252.                      December 18, 1987
  16253.  
  16254.  
  16255.  
  16256.  
  16257.  
  16258.                           - 237 -
  16259.  
  16260.  
  16261.      -    A LeaveNotify event on each window between window
  16262.           A and window B exclusive, with the detail member
  16263.           of each XLeaveWindowEvent structure set to the
  16264.           constant NotifyVirtual.
  16265.  
  16266.      -    An EnterNotify event on window B with the detail
  16267.           member of the XEnterWindowEvent structure set to
  16268.           the constant NotifyInferior.
  16269.  
  16270. o    When the pointer moves from window A to window B, and B
  16271.      is an inferior of A, the X server generates:
  16272.  
  16273.      -    A LeaveNotify event on window A with the detail
  16274.           member of the XLeaveWindowEvent structure set to
  16275.           the constant NotifyInferior.
  16276.  
  16277.      -    An EnterNotify event on each window between window
  16278.           A and window B exclusive, with the detail member
  16279.           of each XEnterWindowEvent structure set to the
  16280.           constant NotifyVirtual.
  16281.  
  16282.      -    An EnterNotify event on window B with the detail
  16283.           member of the XEnterWindowEvent structure set to
  16284.           the constant NotifyAncestor.
  16285.  
  16286. o    When the pointer moves from window A to window B, and
  16287.      window C is their least common ancestor, the X server
  16288.      generates:
  16289.  
  16290.      -    A LeaveNotify event on window A with the detail
  16291.           member of the XLeaveWindowEvent structure set to
  16292.           the constant NotifyNonlinear.
  16293.  
  16294.      -    A LeaveNotify event on each window between window
  16295.           A and window C exclusive, with the detail member
  16296.           of each XLeaveWindowEvent structure set to the
  16297.           constant NotifyNonlinearVirtual.
  16298.  
  16299.      -    An EnterNotify event on each window between window
  16300.           C and window B exclusive, with the detail member
  16301.           of each XEnterWindowEvent structure set to the
  16302.           constant NotifyNonlinearVirtual.
  16303.  
  16304.      -    An EnterNotify event on window B with the detail
  16305.           member of the XEnterWindowEvent structure set to
  16306.           the constant NotifyNonlinear.
  16307.  
  16308. o    When the pointer moves from window A to window B on
  16309.      different screens, the X server:
  16310.  
  16311.      -    Generates a LeaveNotify event on window A with the
  16312.           detail member of the XLeaveWindowEvent structure
  16313.           set to the constant NotifyNonlinear.
  16314.  
  16315.  
  16316.  
  16317.  
  16318.                      December 18, 1987
  16319.  
  16320.  
  16321.  
  16322.  
  16323.  
  16324.                           - 238 -
  16325.  
  16326.  
  16327.      -    If window A is not a root window, it generates a
  16328.           LeaveNotify event on each window above window A up
  16329.           to and including its root, with the detail member
  16330.           of each XLeaveWindowEvent structure set to the
  16331.           constant NotifyNonlinearVirtual.
  16332.  
  16333.      -    If window B is not a root window, it generates an
  16334.           EnterNotify event on each window from window B's
  16335.           root down to but not including window B, with the
  16336.           detail member of each XEnterWindowEvent structure
  16337.           set to the constant NotifyNonlinearVirtual.
  16338.  
  16339.      -    Generates an EnterNotify event on window B with
  16340.           the detail member of the XEnterWindowEvent struc-
  16341.           ture set to the constant NotifyNonlinear.
  16342.  
  16343.      -    Generates an EnterNotify event on window B with
  16344.           the detail member of the XEnterWindowEvent struc-
  16345.           ture set to the constant NotifyNonlinear.
  16346.  
  16347. 8.4.2.2.  Grab and Ungrab Entry/Exit Event Processing
  16348.  
  16349. Pseudo-motion mode EnterNotify and LeaveNotify events are
  16350. generated when a pointer grab activates or deactivates.
  16351. Events in which the pointer grab activates are identified by
  16352. XEnterWindowEvent or XLeaveWindowEvent structures whose mode
  16353. member is set to the constant NotifyGrab.  Events in which
  16354. the pointer grab deactivates are identified by XEnterWin-
  16355. dowEvent or XLeaveWindowEvent structures whose mode member
  16356. is set to the constant NotifyUngrab.  See the discussion of
  16357. XGrabPointer discussed in Chapter 7.
  16358.  
  16359. o    When a pointer grab activates but after any initial
  16360.      warp into a confine_to window, and before generating
  16361.      any actual ButtonPress event that activates the grab,
  16362.      with G the grab_window for the grab and P the window
  16363.      the pointer is in, the X server:
  16364.  
  16365.      -    Generates EnterNotify and LeaveNotify events (see
  16366.           Section 8.4.2.1) with the mode members of the XEn-
  16367.           terWindowEvent and XLeaveWindowEvent structures
  16368.           set to the constant NotifyGrab.  These events are
  16369.           generated as if the pointer were to suddenly warp
  16370.           from its current position in P to some position in
  16371.           G.  However, the pointer does not warp, and the X
  16372.           server uses the pointer position as both the ini-
  16373.           tial and final positions for the events.
  16374.  
  16375. o    When a pointer grab deactivates but after generating
  16376.      any actual ButtonRelease event that deactivates the
  16377.      grab, with G the grab_window for the grab and P the
  16378.      window the pointer is in, the X server:
  16379.  
  16380.  
  16381.  
  16382.  
  16383.  
  16384.                      December 18, 1987
  16385.  
  16386.  
  16387.  
  16388.  
  16389.  
  16390.                           - 239 -
  16391.  
  16392.  
  16393.      -    Generates EnterNotify and LeaveNotify events (see
  16394.           Section 8.4.2.1) with the mode members of the XEn-
  16395.           terWindowEvent and XLeaveWindowEvent structures
  16396.           set to the constant NotifyUngrab.  These events
  16397.           are generated as if the pointer were to suddenly
  16398.           warp from some position in G to its current posi-
  16399.           tion in P.  However, the pointer does not warp,
  16400.           and the X server uses the current pointer position
  16401.           as both the initial and final positions for the
  16402.           events.
  16403.  
  16404. 8.4.3.  Input Focus Events
  16405.  
  16406. This section describes the processing that occurs for the
  16407. input focus events FocusIn and FocusOut.  The X server can
  16408. report FocusIn or FocusOut events to clients wanting infor-
  16409. mation about when the input focus changes.  The input focus
  16410. is where the keyboard input goes.  The keyboard is always
  16411. attached to some window, typically, the root window or a
  16412. top-level window, which is called the focus window.  The
  16413. focus window and the position of the pointer determines the
  16414. window that receives keyboard input.  Clients may need to
  16415. know when the input focus changes.  This is often used to
  16416. control highlighting of areas of the screen.  See also the
  16417. focus member enter/exit events in Section 8.4.2.  This can
  16418. occur when a client calls XGrabKeyboard and XUngrabKeyboard.
  16419.  
  16420. To receive FocusIn and FocusOut events in a client applica-
  16421. tion, you pass a window ID and FocusChangeMask as the
  16422. event_mask argument to XSelectInput.
  16423.  
  16424. The members of the XFocusInEvent and XFocusOutEvent struc-
  16425. tures associated with these events are window, mode, and
  16426. detail.  The window member is set to the window ID of the
  16427. window on which the FocusIn or FocusOut event was generated.
  16428. This is the window used by the X server to report the event.
  16429. The mode member is set to indicate whether the focus events
  16430. are normal focus events, while grabbed focus events, focus
  16431. events when a grab activates, or focus events when a grab
  16432. deactivates.  The X server can set the mode member to the
  16433. corresponding constants NotifyNormal, NotifyWhileGrabbed,
  16434. NotifyGrab, or NotifyUngrab.  The following sections discuss
  16435. how the X server processes normal focus events, while
  16436. grabbed focus events, and grab activate/deactivate focus
  16437. events.
  16438.  
  16439. All FocusOut events caused by a window unmap are generated
  16440. after any UnmapNotify event, but the ordering of FocusOut
  16441. events with respect to generated EnterNotify, LeaveNotify,
  16442. VisibilityNotify, and Expose events is not constrained by
  16443. the X protocol.
  16444.  
  16445. Depending on the event mode, the detail member is set to
  16446. indicate the notify detail and can be one of these
  16447.  
  16448.  
  16449.  
  16450.                      December 18, 1987
  16451.  
  16452.  
  16453.  
  16454.  
  16455.  
  16456.                           - 240 -
  16457.  
  16458.  
  16459. constants:  NotifyAncestor, NotifyVirtual, NotifyInferior,
  16460. NotifyNonlinear, NotifyNonlinearVirtual, NotifyPointer,
  16461. NotifyPointerRoot, or NotifyDetailNone,
  16462.  
  16463. 8.4.3.1.  Normal and While Grabbed Focus Event Processing
  16464.  
  16465. Normal focus events are identified by XFocusInEvent or
  16466. XFocusOutEvent structures whose mode member is set to the
  16467. constant NotifyNormal.  While grabbed focus events are iden-
  16468. tified by XFocusInEvent or XFocusOutEvent structures whose
  16469. mode member is set to the constant NotifyWhileGrabbed.  The
  16470. X server processes normal focus and while grabbed focus
  16471. events according to the following focus scenarios:
  16472.  
  16473. o    When the focus moves from window A to window B, and A
  16474.      is an inferior of B with the pointer in window P, the X
  16475.      server:
  16476.  
  16477.      -    Generates a FocusOut event on window A with the
  16478.           detail member of the XFocusOutEvent structure set
  16479.           to the constant NotifyAncestor.
  16480.  
  16481.      -    Generates a FocusOut event on each window between
  16482.           window A and window B exclusive, with the detail
  16483.           member of each XFocusOutEvent structure set to the
  16484.           constant NotifyVirtual.
  16485.  
  16486.      -    Generates a FocusIn event on window B with the
  16487.           detail member of the XFocusOutEvent structure set
  16488.           to the constant NotifyInferior.
  16489.  
  16490.      -    If window P is an inferior of window B, but window
  16491.           P is not window A or an inferior of window A, it
  16492.           generates a FocusIn event on each window below
  16493.           window B down to and including window P, with the
  16494.           detail member of each XFocusInEvent structure set
  16495.           to the constant NotifyInferior.
  16496.  
  16497. o    When the focus moves from window A to window B, and B
  16498.      is an inferior of A with the pointer in window P, the X
  16499.      server:
  16500.  
  16501.      -    If window P is an inferior of window A, but P is
  16502.           not A, or an inferior of window B, or an ancestor
  16503.           of B, it generates a FocusOut event on each window
  16504.           from window P up to but not including window A (in
  16505.           that order), with the detail member of each XFocu-
  16506.           sOutEvent structure set to the constant
  16507.           NotifyPointer.
  16508.  
  16509.      -    Generates a FocusOut event on window A with the
  16510.           detail member of the XFocusOutEvent structure set
  16511.           to the constant NotifyInferior.
  16512.  
  16513.  
  16514.  
  16515.  
  16516.                      December 18, 1987
  16517.  
  16518.  
  16519.  
  16520.  
  16521.  
  16522.                           - 241 -
  16523.  
  16524.  
  16525.      -    Generates a FocusIn event on each window between
  16526.           window A and window B exclusive, with the detail
  16527.           member of each XFocusInEvent structure set to the
  16528.           constant NotifyVirtual.
  16529.  
  16530.      -    Generates a FocusIn event on window B with the
  16531.           detail member of the XFocusInEvent structure set
  16532.           to the constant NotifyAncestor
  16533.  
  16534. o    When the pointer moves from window A to window B, and
  16535.      window C is their least common ancestor, and with the
  16536.      pointer in window P, the X server:
  16537.  
  16538.      -    If window P is an inferior of window A, it gen-
  16539.           erates a FocusOut event on each window from window
  16540.           P up to but not including window A, with the
  16541.           detail member of the XFocusOutEvent structure set
  16542.           to the constant NotifyPointer.
  16543.  
  16544.      -    Generates a FocusOut event on window A with the
  16545.           detail member of the XFocusOutEvent structure set
  16546.           to the constant NotifyNonlinear.
  16547.  
  16548.      -    Generates a FocusOut event on each window between
  16549.           window A and window C exclusive, with the detail
  16550.           member of each XFocusOutEvent structure set to the
  16551.           constant NotifyNonlinearVirtual.
  16552.  
  16553.      -    Generates a FocusIn event on each window between C
  16554.           and B exclusive, with the detail member of each
  16555.           XFocusInEvent structure set to the constant
  16556.           NotifyNonlinearVirtual.
  16557.  
  16558.      -    Generates a FocusIn event on window B with the
  16559.           detail member of the XFocusInEvent structure set
  16560.           to the constant NotifyNonlinear.
  16561.  
  16562.      -    If window P is an inferior of window B, it gen-
  16563.           erates a FocusIn event on each window below window
  16564.           B down to and including window P, with the detail
  16565.           member of the XFocusInEvent structure set to the
  16566.           constant NotifyPointer.
  16567.  
  16568. o    When the focus moves from window A to window B on dif-
  16569.      ferent screens with the pointer in window P, the X
  16570.      server:
  16571.  
  16572.      -    If window P is an inferior of window A, it gen-
  16573.           erates a FocusOut event on each window from window
  16574.           P up to but not including window A, with the
  16575.           detail member of each XFocusOutEvent structure set
  16576.           to the constant NotifyPointer.
  16577.  
  16578.  
  16579.  
  16580.  
  16581.  
  16582.                      December 18, 1987
  16583.  
  16584.  
  16585.  
  16586.  
  16587.  
  16588.                           - 242 -
  16589.  
  16590.  
  16591.      -    Generates a FocusOut event on window A with the
  16592.           detail member of the XFocusOutEvent structure set
  16593.           to the constant NotifyNonlinear.
  16594.  
  16595.      -    If window A is not a root window, it generates a
  16596.           FocusOut event on each window above window A up to
  16597.           and including its root, with the detail member of
  16598.           each XFocusOutEvent structure set to the constant
  16599.           NotifyNonlinearVirtual.
  16600.  
  16601.      -    If window B is not a root window, it generates a
  16602.           FocusIn event on each window from window B's root
  16603.           down to but not including window B, with the
  16604.           detail member of each XFocusInEvent structure set
  16605.           to the constant NotifyNonlinearVirtual.
  16606.  
  16607.      -    Generates a FocusIn event on window B with the
  16608.           detail member of each XFocusInEvent structure set
  16609.           to the constant NotifyNonlinear.
  16610.  
  16611.      -    If window P is an inferior of window B, it gen-
  16612.           erates a FocusIn event on each window below window
  16613.           B down to and including window P, with the detail
  16614.           member of each XFocusInEvent structure set to the
  16615.           constant NotifyPointer.
  16616.  
  16617. o    You may have specified the focus window by passing the
  16618.      constant PointerRoot (or None), when you called the
  16619.      function XSetInputFocus.  (See Chapter 7.)  When the
  16620.      focus moves from window A to PointerRoot (events sent
  16621.      to the window under the pointer) or None (discard),
  16622.      with the pointer in window P,  the X server:
  16623.  
  16624.      -    If window P is an inferior of window A, it gen-
  16625.           erates a FocusOut event on each window from window
  16626.           P up to but not including window A, with the
  16627.           detail member of each XFocusOutEvent structure set
  16628.           to the constant NotifyPointer.
  16629.  
  16630.      -    Generates a FocusOut event on window A with the
  16631.           detail member of the XFocusOutEvent structure set
  16632.           to NotifyNonlinear.
  16633.  
  16634.      -    If window A is not a root window, it generates a
  16635.           FocusOut event on each window above window A up to
  16636.           and including its root, with the detail member of
  16637.           each XFocusOutEvent structure set to NotifyNon-
  16638.           linearVirtual.
  16639.  
  16640.      -    Generates a FocusIn event on the root window of
  16641.           all screens with the detail member of each XFocu-
  16642.           sInEvent structure set to NotifyPointerRoot (or
  16643.           NotifyDetailNone).
  16644.  
  16645.  
  16646.  
  16647.  
  16648.                      December 18, 1987
  16649.  
  16650.  
  16651.  
  16652.  
  16653.  
  16654.                           - 243 -
  16655.  
  16656.  
  16657.      -    If the new focus is PointerRoot, it generates a
  16658.           FocusIn event on each window from window P's root
  16659.           down to and including window P, with the detail
  16660.           member of each XFocusInEvent structure set to
  16661.           NotifyPointerRoot.
  16662.  
  16663. o    When the focus moves from PointerRoot (events sent to
  16664.      the window under the pointer) or None to window A, with
  16665.      the pointer in window P, the X server:
  16666.  
  16667.      -    If the old focus is PointerRoot, it generates a
  16668.           FocusOut event on each window from window P up to
  16669.           and including window P's root, with the detail
  16670.           member of each XFocusOutEvent structure set to
  16671.           NotifyPointerRoot (in order).
  16672.  
  16673.      -    Generates a FocusOut event on all root windows
  16674.           with the detail member of each XFocusOutEvent
  16675.           structure set to NotifyPointerRoot (or NotifyDe-
  16676.           tailNone).
  16677.  
  16678.      -    If window A is not a root window, it generates a
  16679.           FocusIn event on each window from window A's root
  16680.           down to but not including window A, with the
  16681.           detail member of each XFocusInEvent structure set
  16682.           to NotifyNonlinearVirtual.
  16683.  
  16684.      -    Generates a FocusIn event on window A with the
  16685.           detail member of the XFocusInEvent structure set
  16686.           to the constant NotifyNonlinear.
  16687.  
  16688.      -    If window P is an inferior of window A, it gen-
  16689.           erates a FocusIn event on each window below window
  16690.           A down to and including window P, with the detail
  16691.           member of each XFocusInEvent structure set to the
  16692.           constant NotifyPointer.
  16693.  
  16694. o    When the focus moves from PointerRoot (events sent to
  16695.      the window under the pointer) to None (or vice versa),
  16696.      with the pointer in window P, the X server:
  16697.  
  16698.      -    If the old focus is PointerRoot, it generates a
  16699.           FocusOut event on each window from window P up to
  16700.           and including window P's root, with the detail
  16701.           member of each XFocusOutEvent structure set to
  16702.           NotifyPointerRoot.
  16703.  
  16704.      -    Generates a FocusOut event on all root windows
  16705.           with the detail member of each XFocusOutEvent
  16706.           structure set to the constant NotifyPointerRoot or
  16707.           NotifyDetailNone.
  16708.  
  16709.  
  16710.  
  16711.  
  16712.  
  16713.  
  16714.                      December 18, 1987
  16715.  
  16716.  
  16717.  
  16718.  
  16719.  
  16720.                           - 244 -
  16721.  
  16722.  
  16723.      -    Generates a FocusIn event on all root windows with
  16724.           the detail member of each XFocusInEvent structure
  16725.           set to NotifyDetailNone or NotifyPointerRoot.
  16726.  
  16727.      -    If the new focus is PointerRoot, it generates a
  16728.           FocusIn event on each window from window P's root
  16729.           down to and including window P, with the detail
  16730.           member of each XFocusInEvent structure set to
  16731.           NotifyPointerRoot.
  16732.  
  16733. 8.4.3.2.  Focus Events Generated by Grabs
  16734.  
  16735. Focus events in which the keyboard grab activates are iden-
  16736. tified by XFocusInEvent or XFocusOutEvent structures whose
  16737. mode member is set to the constant NotifyGrab.  Focus events
  16738. in which the keyboard grab deactivates are identified by
  16739. XFocusInEvent or XFocusOutEvent structures whose mode member
  16740. is set to the constant NotifyUngrab.  See the discussion of
  16741. XGrabKeyboard in Chapter 7.
  16742.  
  16743. o    When a keyboard grab activates but before generating
  16744.      any actual KeyPress event that activates the grab with
  16745.      G the grab_window and F the current focus, the X
  16746.      server:
  16747.  
  16748.      -    Generates FocusIn and FocusOut events (as dis-
  16749.           cussed in the previous section), with the mode
  16750.           members of the XFocusInEvent and XFocusOutEvent
  16751.           structures set to the constant NotifyGrab.  These
  16752.           events are generated as if the focus were to
  16753.           change from F to G.
  16754.  
  16755. o    When a keyboard grab deactivates but after generating
  16756.      any actual KeyRelease event that deactivates the grab
  16757.      with G the grab_window and F the current focus, the X
  16758.      server:
  16759.  
  16760.      -    Generates FocusIn and FocusOut events (as dis-
  16761.           cussed in the previous section), with the mode
  16762.           members of the XFocusInEvent and XFocusOutEvent
  16763.           structures set to the constant NotifyUngrab.
  16764.           These events are generated as if the focus were to
  16765.           change from G to F.
  16766.  
  16767. 8.4.4.  Key Map State Notification Event Processing
  16768.  
  16769. This section discusses the processing that occurs for the
  16770. key map state notification event KeymapNotify.  The X server
  16771. reports KeymapNotify events to clients wanting information
  16772. about changes in the keyboard state.  To receive KeymapNo-
  16773. tify events in a client application, you pass a window ID
  16774. and KeymapStateMask as the event_mask argument to XSelectIn-
  16775. put.  The X server generates this event immediately after
  16776. every EnterNotify and FocusIn event.
  16777.  
  16778.  
  16779.  
  16780.                      December 18, 1987
  16781.  
  16782.  
  16783.  
  16784.  
  16785.  
  16786.                           - 245 -
  16787.  
  16788.  
  16789. The members of the XKeymapEvent structure associated with
  16790. this event are window and key_vector.  The window member is
  16791. not used but is present to aid some toolkits.  The
  16792. key_vector member is set to the bit vector of the keyboard.
  16793. Each one bit indicates that the corresponding key is
  16794. currently pressed.  The vector is represented as 32 bytes.
  16795. Byte N (from 0) contains the bits for keys 8N to 8N+7 with
  16796. the least significant bit in the byte representing key 8N.
  16797.  
  16798. 8.4.5.  Exposure Event Processing
  16799.  
  16800. The X protocol does not guarantee to preserve the contents
  16801. of window regions when the windows are obscured or reconfig-
  16802. ured.  Some implementations may preserve the contents of
  16803. windows.  Many other implementations will feel free to des-
  16804. troy the contents of windows when exposed.  X expects client
  16805. applications to assume the responsibility for restoring the
  16806. contents of an exposed window region. (An exposed window
  16807. region describes a formerly obscured window whose region or
  16808. piece of a region becomes visible). Therefore, the X server
  16809. sends exposure events describing the window and the region
  16810. of the window that has been exposed.  A trivial client
  16811. application usually redraws the entire window. A more
  16812. sophisticated client application redraws only the exposed
  16813. region.  The following sections discuss the processing that
  16814. occurs for the Expose, GraphicsExpose, and NoExpose exposure
  16815. events.
  16816.  
  16817. 8.4.5.1.  Expose Event Processing
  16818.  
  16819. The X server can report Expose events to clients wanting
  16820. information about when the contents of window regions have
  16821. been lost.  The circumstances in which the X server gen-
  16822. erates Expose events are not as definite as those for other
  16823. events.  However, the X server never generates Expose events
  16824. on windows whose class you specified as InputOnly.  The X
  16825. server can possibly generate Expose events when a window
  16826. region becomes viewable, but it might only generate this
  16827. event when a region becomes visible.  The X server guaran-
  16828. tees to report contiguously all of the regions exposed by
  16829. some action, such as raising a window.
  16830.  
  16831. To receive Expose events in a client application, you pass a
  16832. window ID and ExposureMask as the event_mask argument to
  16833. XSelectInput.
  16834.  
  16835. The members of the XExposeEvent structure associated with
  16836. this event are window, x, y, width, height, and count.  The
  16837. window member is set to the window ID of the exposed (dam-
  16838. aged) window.  The x and y members are set to the coordi-
  16839. nates relative to the drawable's origin and indicate the
  16840. upper left corner of the rectangle.  The width and height
  16841. members are set to the size (extent) of the rectangle.  The
  16842. count member is set to the number of Expose events that are
  16843.  
  16844.  
  16845.  
  16846.                      December 18, 1987
  16847.  
  16848.  
  16849.  
  16850.  
  16851.  
  16852.                           - 246 -
  16853.  
  16854.  
  16855. to follow.  If count is set to 0 (zero), no more Expose
  16856. events follow for this window.  However, if count is set to
  16857. nonzero, at least count Expose events and possibly more fol-
  16858. low for this window.  Simple applications that do not want
  16859. to optimize redisplay by distinguishing between subareas of
  16860. its window can just ignore all Expose events with nonzero
  16861. counts and perform full redisplays on events with zero
  16862. counts.
  16863.  
  16864. 8.4.5.2.  GraphicsExpose and NoExpose Event Processing
  16865.  
  16866. The X server can report GraphicsExpose events to clients
  16867. wanting information about when a destination region could
  16868. not be computed during a graphics request.  Clients initiate
  16869. a graphics request by calling XCopyArea or XCopyPlane.  The
  16870. X server generates this event whenever a destination region
  16871. could not be computed due to an obscured or out-of-bounds
  16872. source region.  In addition, the X server guarantees to
  16873. report contiguously all of the regions exposed by some
  16874. graphics request (for example, copying an area of a drawable
  16875. to a destination drawable).
  16876.  
  16877. The X server generates NoExpose events whenever a graphics
  16878. request that might produce a GraphicsExpose event does not
  16879. produce any.  In other words, the client is really asking
  16880. for a GraphicsExpose event but instead receives a NoExpose
  16881. event.
  16882.  
  16883. To receive GraphicsExpose or NoExpose events in a client
  16884. application, you must first set the graphics_exposures
  16885. member of the XGCValues structure for the associated graph-
  16886. ics context to the constant True.  You did this when you
  16887. created the graphics context by calling XCreateGC.  Or, you
  16888. may have set the graphics_exposures member after creating
  16889. the graphics context by calling XSetGraphicsExposures.  See
  16890. Chapter 5 for more information on these functions.
  16891.  
  16892. The structures associated with these event types are XGra-
  16893. phicsExposeEvent and XNoExposeEvent, and they have these
  16894. common members: drawable, major_code, and minor_code.  The
  16895. drawable member is set to the drawable ID of the destination
  16896. region on which the copy request was to be performed.  The
  16897. major_code member is set to the graphics request initiated
  16898. by the client, and can be one of the constants X_CopyArea or
  16899. X_CopyPlane.  If X_CopyArea, a call to XCopyArea initiated
  16900. the request.  If X_CopyPlane, a call to XCopyPlane initiated
  16901. the request.  These constants are defined in <X11/Xproto.h>.
  16902. The minor_code member, like the major_code member, indicates
  16903. which graphics request was initiated by the client. However,
  16904. the minor_code member is not defined by the core X protocol
  16905. and will be zero in these cases, but may be used by an
  16906. extension.
  16907.  
  16908. The XGraphicsExposeEvent structure has these additional
  16909.  
  16910.  
  16911.  
  16912.                      December 18, 1987
  16913.  
  16914.  
  16915.  
  16916.  
  16917.  
  16918.                           - 247 -
  16919.  
  16920.  
  16921. members: x, y, width, height, and count. The x and y members
  16922. are set to the coordinates relative to the drawable's origin
  16923. and indicate the upper left corner of the rectangle.  The
  16924. width and height members are set to the size (extent) of the
  16925. rectangle.  The count member is set to the number of Gra-
  16926. phicsExpose events to follow.  If count is set to 0 (zero),
  16927. no more GraphicsExpose events follow for this window.  How-
  16928. ever, if count is set to nonzero, at least that many more,
  16929. and possibly more, GraphicsExpose events are to follow for
  16930. this window.
  16931.  
  16932. 8.4.6.  Window State Notification Event Processing
  16933.  
  16934. The following sections discuss the processing that occurs
  16935. for these window state notification events:  CirculateNo-
  16936. tify, ConfigureNotify, CreateNotify, DestroyNotify, Gravi-
  16937. tyNotify, MapNotify, MappingNotify, ReparentNotify, UnmapNo-
  16938. tify, and VisibilityNotify.
  16939.  
  16940. 8.4.6.1.  CirculateNotify Event Processing
  16941.  
  16942. The X server can report CirculateNotify events to clients
  16943. wanting information about when a window changes its position
  16944. in the stack.  The X server generates this event type when-
  16945. ever a window is actually restacked as a result of a client
  16946. application calling XCirculateSubwindows, XCirculateSubwin-
  16947. dowsUp, or XCirculateSubwindowsDown.
  16948.  
  16949. To receive this event type in a client application, you pass
  16950. the window ID and StructureNotifyMask as the event_mask
  16951. argument to XSelectInput.  You can also receive this event
  16952. type by passing the parent window ID and SubstructureNo-
  16953. tifyMask.
  16954.  
  16955. The members of the XCirculateEvent structure associated with
  16956. this event are event, window, and place.  The event member
  16957. is set to the window ID of the window on which the Circula-
  16958. teNotify event was generated.  This is the window used by
  16959. the X server to report the event.  The window member is set
  16960. to the window ID of the window that was restacked.  The
  16961. place member is set to the window's position after the res-
  16962. tack occurs, and is one of the constants PlaceOnTop or Pla-
  16963. ceOnBottom.  If PlaceOnTop, the window is now on top of all
  16964. siblings.  If PlaceOnBottom, the window is now below all
  16965. siblings.
  16966.  
  16967. 8.4.6.2.  ConfigureNotify Event Processing
  16968.  
  16969. The X server can report ConfigureNotify events to clients
  16970. wanting information about actual changes to a window's
  16971. state, that is, size, position, border, stacking order.  The
  16972. X server generates this event type whenever one of the fol-
  16973. lowing configure window requests made by a client applica-
  16974. tion actually completes:
  16975.  
  16976.  
  16977.  
  16978.                      December 18, 1987
  16979.  
  16980.  
  16981.  
  16982.  
  16983.  
  16984.                           - 248 -
  16985.  
  16986.  
  16987. o    A window's size, position, border, and stacking order
  16988.      is reconfigured as a result of calling XConfigureWin-
  16989.      dow.
  16990.  
  16991. o    The window's position in the stacking order is changed
  16992.      as a result of calling XLowerWindow, XRaiseWindow, or
  16993.      XRestackWindows.
  16994.  
  16995. o    A window is moved as a result of calling XMoveWindow.
  16996.  
  16997. o    A window's size is changed as a result of calling
  16998.      XResizeWindow.
  16999.  
  17000. o    A window's size and location is changed as a result of
  17001.      calling XMoveResizeWindow.
  17002.  
  17003. o    A window is mapped and its position in the stacking
  17004.      order is changed as a result of calling XMapRaised.
  17005.  
  17006. o    A window's border width is changed as a result of cal-
  17007.      ling XSetWindowBorderWidth.
  17008.  
  17009. To receive this event type in a client application, you pass
  17010. the window ID and StructureNotifyMask as the event_mask
  17011. argument to XSelectInput.  You can also receive this event
  17012. type by passing the parent window ID and SubstructureNo-
  17013. tifyMask.
  17014.  
  17015. The members of the XConfigureEvent structure associated with
  17016. this event are event, window, x, y, width, height,
  17017. border_width, above, and override_redirect.  The event
  17018. member is set to the window ID of the window on which the
  17019. ConfigureNotify event was generated.  This is the window
  17020. used by the X server to report the event.  The window member
  17021. is set to the window ID of the window whose size, position,
  17022. border, and/or stacking order was changed.
  17023.  
  17024. The x and y members are set to the coordinates relative to
  17025. the new parent window's origin and indicate the position of
  17026. the upper left outside corner of the window.  The width and
  17027. height members are set to the inside size of the window, not
  17028. including the border.  The border_width member is set to the
  17029. width of the window's border, in pixels.
  17030.  
  17031. The above member is set to the window ID of the sibling win-
  17032. dow and is used for stacking operations.  If the X server
  17033. sets this member to the constant None, the window whose
  17034. state was changed is on the bottom of the stack with respect
  17035. to sibling windows.  However, if this member is set to the
  17036. ID of a sibling window, the X server places the window whose
  17037. state was changed on top of this sibling window.
  17038.  
  17039. The override_redirect member is set to the constant you
  17040. specified for the override_redirect member of the
  17041.  
  17042.  
  17043.  
  17044.                      December 18, 1987
  17045.  
  17046.  
  17047.  
  17048.  
  17049.  
  17050.                           - 249 -
  17051.  
  17052.  
  17053. XSetWindowAttributes structure when you created the window
  17054. or changed its attributes.  This constant is either True or
  17055. False.  Window manager clients normally should ignore this
  17056. event if the override_redirect member is True.
  17057.  
  17058. 8.4.6.3.  CreateNotify Event Processing
  17059.  
  17060. The X server can report CreateNotify events to clients want-
  17061. ing information about creation of windows.  The X server
  17062. generates this event whenever a client application creates a
  17063. window by calling XCreateWindow or XCreateSimpleWindow.
  17064.  
  17065. To receive this event type in a client application, you pass
  17066. the window ID of the parent window and SubstructureNo-
  17067. tifyMask as the event_mask argument to XSelectInput.
  17068.  
  17069. The members of the XCreateWindowEvent structure associated
  17070. with this event are parent, window, x, y, width, height,
  17071. border_width, and override_redirect.  The parent member is
  17072. set to the window ID of the created window's parent.  The
  17073. window member specifies the window ID of the created window.
  17074. The x and y members are set to the created window's coordi-
  17075. nates relative to the inside of the parent window's borders
  17076. and indicate the position of the upper left outside corner
  17077. of the created window.  The width and height members are set
  17078. to the inside size of the created window not including the
  17079. border, and are always a nonzero value.  The border_width
  17080. member is set to the width of the created window's border,
  17081. in pixels.  The override_redirect member is set to the con-
  17082. stant you specified for the override_redirect member of the
  17083. XSetWindowAttributes structure when you created the window
  17084. or changed its attributes.  This constant is either True or
  17085. False.  Window manager clients normally should ignore this
  17086. event if the override_redirect member is True.
  17087.  
  17088. 8.4.6.4.  DestroyNotify Event Processing
  17089.  
  17090. The X server can report DestroyNotify events to clients
  17091. wanting information about which windows are destroyed.  The
  17092. X server generates this event whenever a client application
  17093. destroys a window by calling XDestroyWindow or XDestroy-
  17094. Subwindows.
  17095.  
  17096. The ordering of the DestroyNotify events is such that for
  17097. any given window, DestroyNotify is generated on all inferi-
  17098. ors of the window before being generated on the window
  17099. itself. The ordering among siblings and across subhierar-
  17100. chies is not otherwise constrained by the X protocol.
  17101.  
  17102. To receive this event type in a client application, you pass
  17103. the window ID of the parent window and SubstructureNo-
  17104. tifyMask as the event_mask argument to XSelectInput.  You
  17105. can also receive this event type by passing the window ID of
  17106. the window and SubstructureNotifyMask.
  17107.  
  17108.  
  17109.  
  17110.                      December 18, 1987
  17111.  
  17112.  
  17113.  
  17114.  
  17115.  
  17116.                           - 250 -
  17117.  
  17118.  
  17119. The members of the XDestroyWindowEvent structure associated
  17120. with this event are event and window.  The event member is
  17121. set to the window ID of the window on which the DestroyNo-
  17122. tify event was generated.  This is the window used by the X
  17123. server to report the event.  The window member is set to the
  17124. window ID of the window that is destroyed.
  17125.  
  17126. 8.4.6.5.  GravityNotify Event Processing
  17127.  
  17128. The X server can report GravityNotify events to clients
  17129. wanting information about when a window is moved because of
  17130. a change in the size of its parent.  The X server generates
  17131. this event whenever a client application actually moves a
  17132. child window as a result of resizing its parent by calling
  17133. XConfigureWindow, XMoveResizeWindow, and XResizeWindow.
  17134.  
  17135. To receive this event type in a client application, you pass
  17136. the window ID of the window and StructureNotifyMask as the
  17137. event_mask argument to XSelectInput.  You can also receive
  17138. this event type by passing the window ID of the parent win-
  17139. dow and SubstructureNotifyMask.
  17140.  
  17141. The members of the XGravityEvent structure associated with
  17142. this event are event, window, x, and y.  The event member is
  17143. set to the window ID of the window on which the GravityNo-
  17144. tify event was generated.  This is the window used by the X
  17145. server to report the event.  The window member is set to the
  17146. window ID of the child window that was moved.  The x and y
  17147. members are set to the coordinates relative to the new
  17148. parent window's origin and indicate the position of the
  17149. upper left outside corner of the window.
  17150.  
  17151. 8.4.6.6.  MapNotify Event Processing
  17152.  
  17153. The X server can report MapNotify events to clients wanting
  17154. information about which windows are mapped.  The X server
  17155. generates this event type whenever a client application
  17156. changes the window's state from unmapped to mapped by cal-
  17157. ling XMapWindow, XMapRaised, or XMapSubwindows.
  17158.  
  17159. To receive this event type, you pass the window ID of the
  17160. window and StructureNotifyMask as the event_mask argument to
  17161. XSelectInput.  You can also receive this event type by pass-
  17162. ing the window ID of a parent window and SubstructureNo-
  17163. tifyMask.
  17164.  
  17165. The members of the XMapEvent structure associated with this
  17166. event are event, window, and override_redirect.  The event
  17167. member is set to the window ID of the window on which the
  17168. MapNotify event was generated.  This is the window used by
  17169. the X server to report the event.  The window member is set
  17170. to the window ID of the window that was mapped.  The
  17171. override_redirect member is set to the constant you speci-
  17172. fied for the override_redirect member of the
  17173.  
  17174.  
  17175.  
  17176.                      December 18, 1987
  17177.  
  17178.  
  17179.  
  17180.  
  17181.  
  17182.                           - 251 -
  17183.  
  17184.  
  17185. XSetWindowAttributes structure, when you created the window
  17186. or changed its attributes.  This constant is either True or
  17187. False.  Window manager clients normally should ignore this
  17188. event if the override_redirect member is True.
  17189.  
  17190. 8.4.6.7.  MappingNotify Event Processing
  17191.  
  17192. The X server reports MappingNotify events to all clients.
  17193. There is no mechanism to express disinterest in this event.
  17194. The X server generates this event type whenever a client
  17195. application calls:
  17196.  
  17197. o    XSetModifierMapping to indicate which keycodes are to
  17198.      be used as modifiers. The status reply must be Mapping-
  17199.      Success.
  17200.  
  17201. o    XChangeKeyboardMapping to change the keyboard mapping.
  17202.  
  17203. o    XSetPointerMapping to set the pointer mapping.  The
  17204.      status reply must be MappingSuccess.
  17205.  
  17206. See Chapter 7 for a discussion of these functions.
  17207.  
  17208. The members of the XMappingEvent structure associated with
  17209. this event are window (not used and only present to aid cer-
  17210. tain toolkits), request, first_keycode, and count.  The
  17211. request member is set to indicate the kind of mapping change
  17212. that occurred, and can be one of the constants MappingModif-
  17213. ier, MappingKeyboard, MappingPointer.  If MappingModifier,
  17214. the specified keycodes are used as modifiers.  If Mapping-
  17215. Keyboard, the keyboard mapping is changed.  If Mapping-
  17216. Pointer, the pointer button mapping is set. The
  17217. first_keycode and count members are set only if the request
  17218. member was set to MappingKeyboard.  If this is the case,
  17219. these members are set to numbers that indicate the range of
  17220. altered keyboards.  Thus, the number in first_keycode
  17221. represents the first number in the range, and the number in
  17222. count represents the last number in the range.
  17223.  
  17224. To update the client application's knowledge of the key-
  17225. board, you should call XRefreshKeyboardMapping.  See Chapter
  17226. 10 for a discussion of this function.
  17227.  
  17228. 8.4.6.8.  ReparentNotify Event Processing
  17229.  
  17230. The X server can report ReparentNotify events to clients
  17231. wanting information about changing a window's parent.  The X
  17232. server generates this event whenever a client application
  17233. calls XReparentWindow and the window is actually reparented.
  17234.  
  17235. To receive this event type in a client application, you pass
  17236. the window ID of the old or the new parent window and Sub-
  17237. StructureNotifyMask as the event_mask argument to XSelectIn-
  17238. put.  You can also receive this event type by passing the
  17239.  
  17240.  
  17241.  
  17242.                      December 18, 1987
  17243.  
  17244.  
  17245.  
  17246.  
  17247.  
  17248.                           - 252 -
  17249.  
  17250.  
  17251. window ID and StructureNotifyMask.
  17252.  
  17253. The members of the XReparentEvent structure associated with
  17254. this event are event, window, parent, x, y, and
  17255. override_redirect.  The event member is set to the window ID
  17256. of the window on which the ReparentNotify event was gen-
  17257. erated and on which you requested notification by using
  17258. XSelectInput.  This is the window used by the X server to
  17259. report the event.  The window member is set to the window ID
  17260. of the window that was reparented.  The parent member is set
  17261. to the window ID of the new parent window.  The x and y
  17262. members are set to the reparented window's coordinates rela-
  17263. tive to the new parent window's origin and define the upper
  17264. left outer corner of the reparented window.  The
  17265. override_redirect member is set to the constant you speci-
  17266. fied for the override_redirect member of the XSetWindowAt-
  17267. tributes structure when you created the window or changed
  17268. its attributes.  This constant is either True or False.
  17269. Window manager clients normally should ignore this event if
  17270. the override_redirect member is True.
  17271.  
  17272. 8.4.6.9.  UnmapNotify Event Processing
  17273.  
  17274. The X server can report UnmapNotify events to clients want-
  17275. ing information about which windows are unmapped.  The X
  17276. server generates this event type whenever a client applica-
  17277. tion changes the window's state from mapped to unmapped by
  17278. calling XUnmapWindow or XUnmapSubwindows.
  17279.  
  17280. To receive this event type, you pass the window ID and
  17281. StructureNotifyMask as the event_mask argument to XSelectIn-
  17282. put.  You can also receive this event type by passing the
  17283. window ID of the parent window and SubstructureNotifyMask.
  17284.  
  17285. The members of the XUnmapEvent structure associated with
  17286. this event are event, window, and from_configure.  The event
  17287. member is set to the window ID of the window on which the
  17288. UnmapNotify event was generated and on which you requested
  17289. notification by using XSelectInput.  This is the window used
  17290. by the X server to report the event.  The window member is
  17291. set to the window ID of the window that was unmapped.  The
  17292. from_configure member is set to the constant True if the
  17293. event was generated as a result of a resizing of the
  17294. window's parent when the window itself had a win_gravity of
  17295. UnmapGravity.
  17296.  
  17297. 8.4.6.10.  VisibilityNotify Event Processing
  17298.  
  17299. The X server can report VisibilityNotify events to clients
  17300. wanting any change in the visibility of the specified win-
  17301. dow.  A region of a window is visible if someone looking at
  17302. the screen can actually see it.  The X server generates this
  17303. event whenever the visibility changes state. However, this
  17304. event is never generated for windows whose class is
  17305.  
  17306.  
  17307.  
  17308.                      December 18, 1987
  17309.  
  17310.  
  17311.  
  17312.  
  17313.  
  17314.                           - 253 -
  17315.  
  17316.  
  17317. InputOnly.  X ignores any subwindows in this computation.
  17318.  
  17319. All VisibilityNotify events caused by a hierarchy change are
  17320. generated after any hierarchy event ( UnmapNotify, MapNo-
  17321. tify, ConfigureNotify, GravityNotify, CirculateNotify)
  17322. caused by that change.  Any VisibilityNotify event on a
  17323. given window is generated before any Expose events on that
  17324. window, but it is not required that all VisibilityNotify
  17325. events on all windows be generated before all Expose events
  17326. on all windows. The ordering of VisibilityNotify events with
  17327. respect to FocusOut, EnterNotify, and LeaveNotify events is
  17328. not constrained by the X protocol.
  17329.  
  17330. To receive this event type in a client application, you pass
  17331. the window ID of the window and VisibilityChangeMask as the
  17332. event_mask argument to XSelectInput.
  17333.  
  17334. The members of the XVisibilityEvent structure associated
  17335. with this event are window and state. The window member is
  17336. set to the window whose visibility state changes.  The state
  17337. member is set to the state of the window's visibility, and
  17338. can be one of the constants VisibilityUnobscured, Visibili-
  17339. tyPartiallyObscured, or VisibilityFullyObscured.  The X
  17340. server ignores all of a window's subwindows when determining
  17341. the visibility state of the window and processes Visibili-
  17342. tyNotify events according to the following:
  17343.  
  17344. o    When the window changes state from partially or fully
  17345.      obscured or not viewable to viewable and completely
  17346.      unobscured, the X server generates the event with the
  17347.      state member of the XVisibilityEvent structure set to
  17348.      the constant VisibilityUnobscured.
  17349.  
  17350. o    When the window changes state from viewable and com-
  17351.      pletely unobscured or from not viewable to viewable and
  17352.      partially obscured, the X server generates the event
  17353.      with the state member of the XVisibilityEvent structure
  17354.      set to the constant VisibilityPartiallyObscured.
  17355.  
  17356. o    When the window changes state from viewable and com-
  17357.      pletely unobscured or viewable and partially obscured
  17358.      or from not viewable to viewable and fully obscured,
  17359.      the X server generates the event with the state member
  17360.      of the XVisibilityEvent structure set to the constant
  17361.      VisibilityFullyObscured.
  17362.  
  17363. 8.4.7.  Structure Control Event Processing
  17364.  
  17365. The following sections discuss the processing that occurs
  17366. for these structure control events:  CirculateRequest, Con-
  17367. figureRequest, MapRequest, and ResizeRequest.  These are
  17368. only generated when clients have structure control enabled
  17369. and are generally only of interest to window managers.
  17370.  
  17371.  
  17372.  
  17373.  
  17374.                      December 18, 1987
  17375.  
  17376.  
  17377.  
  17378.  
  17379.  
  17380.                           - 254 -
  17381.  
  17382.  
  17383. 8.4.7.1.  CirculateRequest Event
  17384.  
  17385. The X server can report CirculateRequest events to clients
  17386. wanting information about when another client initiates a
  17387. circulate window request on a specified parent window. The X
  17388. server generates this event type whenever a client initiates
  17389. a circulate window request on a parent window, and a window
  17390. actually needs to be restacked. The client initiates a cir-
  17391. culate window request on the parent window by calling XCir-
  17392. culateSubwindows, XCirculateSubwindowsUp, or XCircula-
  17393. teSubwindowsDown.
  17394.  
  17395. To receive this event type in a client application, you pass
  17396. the window ID of the parent window and Substruc-
  17397. tureRedirectMask as the event_mask argument to XSelectInput.
  17398. In the future, the circulate window request for the speci-
  17399. fied window will not be not executed, and, thus, the
  17400. window's position in the stack is not changed.  For example,
  17401. suppose a client application calls XCirculateSubwindowsUp to
  17402. raise a specified window to the top of the stack.  If you
  17403. had selected SubstructureRedirectMask on the parent window,
  17404. the X server reports to you a CirculateRequest event and
  17405. does not raise the specified window to the top of the stack.
  17406.  
  17407. The members of the XCirculateRequestEvent structure associ-
  17408. ated with this event are parent, window, and place.  The
  17409. parent member is set to the window ID of the parent window.
  17410. The window member is set to the window ID of the window to
  17411. be restacked.  The place member is set to what the new posi-
  17412. tion in the stacking order should be, and is one of the con-
  17413. stants PlaceOnTop or PlaceOnBottom.  If PlaceOnTop, the win-
  17414. dow should be on top of all siblings.  If PlaceOnBottom, the
  17415. window should be below all siblings.
  17416.  
  17417. 8.4.7.2.  ConfigureRequest Event
  17418.  
  17419. The X server can report ConfigureRequest events to clients
  17420. wanting information about when another client initiates a
  17421. configure window request on a specified window. The config-
  17422. ure window request attempts to reconfigure a window's size,
  17423. position, border, and stacking order.  The X server gen-
  17424. erates this event whenever a client initiates a configure
  17425. window request on a window by calling XConfigureWindow,
  17426. XLowerWindow, XRaiseWindow, XMapRaised, XMoveResizeWindow,
  17427. XMoveWindow, XResizeWindow, XRestackWindows, or XSetWin-
  17428. dowBorderWidth.
  17429.  
  17430. To receive this event type in a client application, you pass
  17431. the window ID of the parent window and Substruc-
  17432. tureRedirectMask as the event_mask argument to XSelectInput.
  17433. It is generated when a ConfigureWindow request is issued on
  17434. the window by another client.  For example, suppose a client
  17435. application calls XLowerWindow to lower a window.  If you
  17436. had selected SubstructureRedirectMask on the parent window,
  17437.  
  17438.  
  17439.  
  17440.                      December 18, 1987
  17441.  
  17442.  
  17443.  
  17444.  
  17445.  
  17446.                           - 255 -
  17447.  
  17448.  
  17449. and if the override_redirect member of the XSetWindowAttri-
  17450. butes structure associated with the specified window is set
  17451. to False, the X server reports a ConfigureRequest event to
  17452. you and does not lower the specified window.
  17453.  
  17454. The members of the XConfigureRequestEvent structure associ-
  17455. ated with this event are parent, window, x, y, width,
  17456. height, border_width, above, detail, and value_mask.  The
  17457. parent member is set to the window ID of the parent window.
  17458. The window member is set to the window ID whose size, posi-
  17459. tion, border width, and/or stacking order is to be reconfig-
  17460. ured.  The x and y members are set to the coordinates rela-
  17461. tive to the parent window's origin and indicate the desired
  17462. position of the upper left outside corner of the reconfig-
  17463. ured window.  The width and height members are set to the
  17464. desired inside size of the reconfigured window (not includ-
  17465. ing the border) and are always a nonzero value.  The
  17466. border_width member is set to the desired width of the
  17467. reconfigured window's border, in pixels.  The above member
  17468. is set to the window ID of the sibling window and is used
  17469. for stacking operations.  If the X server sets this member
  17470. to the constant None, then the reconfigured window should be
  17471. placed on the bottom of the stack with respect to sibling
  17472. windows.  However, if this member is set to the ID of a
  17473. sibling window, the reconfigured window wants to be placed
  17474. on top of this sibling window.
  17475.  
  17476. If not given in the request, the detail member is set to the
  17477. constant Above.  This member could also be set to the con-
  17478. stants Below, TopIf, BottomIf, or Opposite.  The value_mask
  17479. member is set to indicate which components were specified in
  17480. the request.  The value_mask and the corresponding values
  17481. are reported as given in the request.
  17482.  
  17483. 8.4.7.3.  MapRequest Event
  17484.  
  17485. The X server can report MapRequest events to clients wanting
  17486. information about another client's desire to map (place)
  17487. windows.  A window is considered mapped when a map window
  17488. request completes.  The X server generates this event when-
  17489. ever a client initiates a map window request on an unmapped
  17490. window whose override_redirect member is set to False.
  17491. Clients initiate map window requests by calling XMapWindow,
  17492. XMapRaised, or XMapSubwindows.
  17493.  
  17494. To receive this event type in a client application, you pass
  17495. the window ID of the parent window and Substruc-
  17496. tureRedirectMask as the event_mask argument to XSelectInput.
  17497. This means another client's attempts to map the window by
  17498. calling one of the map window request functions will fail,
  17499. and you will be sent a MapRequest instead.  For example,
  17500. suppose a client application calls XMapWindow to map a win-
  17501. dow.  If you (usually your window manager) had selected Sub-
  17502. structureRedirectMask on the parent window, and if the
  17503.  
  17504.  
  17505.  
  17506.                      December 18, 1987
  17507.  
  17508.  
  17509.  
  17510.  
  17511.  
  17512.                           - 256 -
  17513.  
  17514.  
  17515. override_redirect member of the XSetWindowAttributes struc-
  17516. ture associated with the specified window is set to False,
  17517. the X server reports to you a MapRequest event and does not
  17518. map the specified window.  Thus, this event gives your win-
  17519. dow manager client the ability to control the placement of
  17520. subwindows.
  17521.  
  17522. The members of the XMapRequestEvent structure associated
  17523. with this event are parent and window.  The parent member is
  17524. set to the window ID of the parent window.  The window
  17525. member is set to the window ID of the window to be mapped.
  17526.  
  17527. 8.4.7.4.  ResizeRequest Event Processing
  17528.  
  17529. The X server can report ResizeRequest events to clients
  17530. wanting information about another client's attempts to
  17531. change the size of a window.  The X server generates this
  17532. event whenever some other client attempts to change the size
  17533. of the specified window by calling XConfigureWindow,
  17534. XResizeWindow, or XMoveResizeWindow.
  17535.  
  17536. To receive this event type in a client application, you pass
  17537. a window ID and ResizeRedirect as the event_mask argument to
  17538. XSelectInput.  You will be sent the ResizeRedirect event,
  17539. and any attempts to change the size by other clients will
  17540. fail.
  17541.  
  17542. The members of the XResizeRequestEvent structure associated
  17543. with this event are window, width, and height.  The window
  17544. member is set to the window ID of the window whose size
  17545. another client attempted to change.  The width and height
  17546. members are set to the inside size of the window, not
  17547. including the border.
  17548.  
  17549. 8.4.8.  Color Map State Notification Event Processing
  17550.  
  17551. This section discusses the processing that occurs for the
  17552. color map notification event ColormapNotify.  The X server
  17553. can report ColormapNotify events to clients wanting informa-
  17554. tion about when the color map changes and when a color map
  17555. is installed or uninstalled. The X server generates this
  17556. event type whenever a client application:
  17557.  
  17558. o    Changes the colormap member of the XSetWindowAttributes
  17559.      structure by calling XChangeWindowAttributes or
  17560.      XFreeColormap.
  17561.  
  17562. o    Installs or uninstalls the color map by calling XIn-
  17563.      stallColormap or XUninstallColormap.
  17564.  
  17565. To receive this event type in a client application, you pass
  17566. the window ID of the window and ColormapChangeMask to the
  17567. event_mask argument of XSelectInput.
  17568.  
  17569.  
  17570.  
  17571.  
  17572.                      December 18, 1987
  17573.  
  17574.  
  17575.  
  17576.  
  17577.  
  17578.                           - 257 -
  17579.  
  17580.  
  17581. The members of the XColormapEvent structure associated with
  17582. this event are window, colormap, new, and state.  The window
  17583. member is set to the window ID of the window whose associ-
  17584. ated color map is changed, installed, or uninstalled.  For a
  17585. color map that is changed by a call to XChangeWindowAttri-
  17586. butes, installed, or uninstalled, the colormap member is set
  17587. to the colormap resource ID of the color map associated with
  17588. the window. For a color map that is changed by a call to
  17589. XFreeColormap, the colormap member is set to the constant
  17590. None.  The new member is set to indicate whether the color
  17591. map for the specified window was changed or installed or
  17592. uninstalled, and it can be one of the constants True or
  17593. False.  If True, the color map was changed.  If False, the
  17594. color map was installed or uninstalled.  The state member is
  17595. always set to indicate whether the color map is installed or
  17596. uninstalled, and it can be one of the corresponding con-
  17597. stants ColormapInstalled or ColormapUninstalled.
  17598.  
  17599. 8.4.9.  Client Communication Event Processing
  17600.  
  17601. The following sections discuss the processing that occurs
  17602. for these client communication events:  ClientMessage, Pro-
  17603. pertyNotify, SelectionClear, SelectionNotify, and Selection-
  17604. Request.
  17605.  
  17606. 8.4.9.1.  ClientMessage Event Processing
  17607.  
  17608. The X server generates ClientMessage events only when a
  17609. client calls the function XSendEvent.  See Section 8.8 in
  17610. this chapter for information on how to send an event.
  17611.  
  17612. The members of the XClientMessageEvent structure associated
  17613. with this event are window, message_type, format, and data.
  17614. The window member is set to the window ID of the window to
  17615. which the event was sent.  The message_type member is set to
  17616. an atom that indicates how the data is to be interpreted by
  17617. the receiving client.  The format member is set to 8, 16, or
  17618. 32 and specifies whether the data should be viewed as a list
  17619. of bytes, shorts, or longs.  The data member is a union that
  17620. contains the members b, s, and l.  The b, s, and l members
  17621. represent data of twenty 8-bit values, ten 16-bit values,
  17622. and five 32-bit values.  Particular message types might not
  17623. make use of all these values.  The X server places no
  17624. interpretation on the values in the message_type or data
  17625. members.
  17626.  
  17627. 8.4.9.2.  PropertyNotify Event Processing
  17628.  
  17629. The X server can report PropertyNotify events to clients
  17630. wanting information about property changes for a specified
  17631. window.  A property consists of an atom name, an atom type,
  17632. a data format, and some property data.  The X server gen-
  17633. erates this event whenever a client application calls
  17634. XChangeProperty, XDeleteProperty, XRotateWindowProperties,
  17635.  
  17636.  
  17637.  
  17638.                      December 18, 1987
  17639.  
  17640.  
  17641.  
  17642.  
  17643.  
  17644.                           - 258 -
  17645.  
  17646.  
  17647. XGetProperty.
  17648.  
  17649. See Chapter 4 for more information on these functions and
  17650. the property concept.
  17651.  
  17652. To receive this event type, you pass the window ID and Pro-
  17653. pertyChangeMask as the event_mask argument to XSelectInput.
  17654.  
  17655. The members of the XPropertyEvent structure associated with
  17656. this event are window, atom, time, and state. The window
  17657. member is set to the window ID of the window whose associ-
  17658. ated property was changed.  The atom member is set to the
  17659. property's atom and indicates which property was changed or
  17660. desired.  The time member is set to the server time when the
  17661. property was changed.  The state member is set to indicate
  17662. whether the property was changed to a new value or deleted,
  17663. and it can be one of the corresponding constants Proper-
  17664. tyNewValue or PropertyDelete.
  17665.  
  17666. 8.4.9.3.  SelectionClear Event Processing
  17667.  
  17668. The X server reports SelectionClear events to the current
  17669. owner of a selection.  The X server generates this event
  17670. type on the window losing ownership of the selection to a
  17671. new owner.  This sequence of events could occur whenever a
  17672. client calls XSetSelectionOwner.  See Section 4.4 for infor-
  17673. mation on this function and on selections.
  17674.  
  17675. The members of the XSelectionClearEvent structure associated
  17676. with this event are window, selection, and time.  The window
  17677. member is set to the ID of the window losing ownership of
  17678. the selection.  The selection member is set to the selection
  17679. atom.  The time member is set to the last change time
  17680. recorded for the selection.  The owner member is the window
  17681. that was specified by the current owner in its XSetSelec-
  17682. tionOwner call.
  17683.  
  17684. 8.4.9.4.  SelectionRequest Event Processing
  17685.  
  17686. The X server reports SelectionRequest events to the owner of
  17687. a selection.  The X server generates this event whenever a
  17688. client requests a selection conversion by calling XConvert-
  17689. Selection, and the specified selection is owned by a window.
  17690.  
  17691. The members of the XSelectionRequestEvent structure associ-
  17692. ated with this event are owner, requestor, selection, tar-
  17693. get, property, and time.  The owner member is set to the
  17694. window ID of the window owning the selection.  The owner
  17695. member is the window that was specified by the current owner
  17696. in its XSetSelectionOwner call.  The requestor member is set
  17697. to the window ID of the window requesting the selection.
  17698. The selection member is set to the atom that indicates which
  17699. selection.  For example, PRIMARY is used to indicate the
  17700. primary selection.  The target member is set to the atom
  17701.  
  17702.  
  17703.  
  17704.                      December 18, 1987
  17705.  
  17706.  
  17707.  
  17708.  
  17709.  
  17710.                           - 259 -
  17711.  
  17712.  
  17713. that indicates the type the selection is desired in.  The
  17714. property member can be the atom or the property or None.
  17715. The time member is set to the time and is a timestamp,
  17716. expressed in milliseconds, or the constant CurrentTime from
  17717. the ConvertSelection request.
  17718.  
  17719. The client whose window owns the selection should do the
  17720. following:
  17721.  
  17722. o    Convert the selection based on the atom contained in
  17723.      the target member.
  17724.  
  17725. o    If a property was specified (that is, the property
  17726.      member is set), the client should store the result as
  17727.      that property on the requestor window and then send a
  17728.      SelectionNotify event to the requestor by calling XSen-
  17729.      dEvent with an empty event-mask, that is the event
  17730.      should be sent to the creator of the requestor window.
  17731.  
  17732. o    If the selection cannot be converted as requested, the
  17733.      client should send a SelectionNotify event with the
  17734.      property set to the constant None.
  17735.  
  17736. 8.4.9.5.  SelectionNotify Event Processing
  17737.  
  17738. This event is generated by the X server in response to a
  17739. XConvertSelectionrequest When there is an owner, it should
  17740. be generated by the owner of the selection by using XSen-
  17741. dEvent.  The owner of a selection should send this event to
  17742. a requestor when a selection has been converted and stored
  17743. as a property.  or when a selection conversion could not be
  17744. performed (indicated with the property member set to None).
  17745.  
  17746. The members of the XSelectionEvent structure associated with
  17747. this event are requestor, selection, target, property, and
  17748. time.  The requestor member is set to the window ID of the
  17749. window associated with the requestor of the selection.  The
  17750. selection member is set to the atom that indicates the kind
  17751. of selection.  For example, PRIMARY is used for the primary
  17752. selection.  The target member is set to the atom that indi-
  17753. cates the desired type.  For example, PIXMAP is used for a
  17754. pixmap.  The property member is set to the atom that indi-
  17755. cates which property the result was stored on.  If none were
  17756. possible, then the property member will be set to None.  The
  17757. time member is set to the time in which the conversion took
  17758. place and can be a timestamp, expressed in milliseconds, or
  17759. the constant CurrentTime.
  17760.  
  17761. 8.5.  Selecting Events
  17762.  
  17763. There are two ways to select the events you want reported to
  17764. your client application.  One way is to set the event_mask
  17765. member of the XSetWindowAttributes structure when you call
  17766. XCreateWindow and XChangeWindowAttributes.  See Chapter 3
  17767.  
  17768.  
  17769.  
  17770.                      December 18, 1987
  17771.  
  17772.  
  17773.  
  17774.  
  17775.  
  17776.                           - 260 -
  17777.  
  17778.  
  17779. for a discussion of these functions.  Another way is to use
  17780. XSelectInput.  Section 8.4 discussed the processing that
  17781. occurs for each event type associated with the event mask
  17782. you pass to XSelectInput.  Event Handling
  17783.  
  17784. The definition for XSelectInput is:
  17785.  
  17786. XSelectInput(display, w, event_mask)
  17787.       Display *display;
  17788.       Window w;
  17789.       unsigned long event_mask;
  17790.  
  17791.  
  17792. display   Specifies the connection to the X server.
  17793.  
  17794. w         Specifies the window ID.  Client applications
  17795.           interested in an event for a particular window
  17796.           pass that window's ID.
  17797.  
  17798. event_maskSpecifies the event mask.  This mask is the bit-
  17799.           wise inclusive OR of one or more of the valid
  17800.           event mask bits.
  17801.  
  17802. The XSelectInput function requests that the X server report
  17803. the events associated with the event masks that you pass to
  17804. the event_mask argument.  Initially, X will not report any
  17805. of these events.  See Section 8.3 for a discussion of these
  17806. event masks.
  17807.  
  17808. Events are reported relative to a window.  If a window is
  17809. not interested in an event, it usually propagates to the
  17810. closest ancestor that is interested, unless the
  17811. do_not_propagate mask prohibits it.
  17812.  
  17813. A call to XSelectInput overrides any previous call to
  17814. XSelectInput for the same window from the same client but
  17815. not for other clients.  Two different clients can select
  17816. events on the same window with the following restrictions:
  17817.  
  17818. o    Multiple clients can select events on the same window
  17819.      because their event masks are disjoint.  After the X
  17820.      server generates an event, it reports it to all
  17821.      interested clients.
  17822.  
  17823. o    Only one client at a time can select CirculateRequest,
  17824.      ConfigureRequest, or MapRequest events, which are asso-
  17825.      ciated with the event mask SubstructureRedirectMask.
  17826.  
  17827. o    Only one client at a time can select a ResizeRequest
  17828.      event, which is associated with the event mask Resiz-
  17829.      eRedirectMask.
  17830.  
  17831.  
  17832.  
  17833.  
  17834.  
  17835.  
  17836.                      December 18, 1987
  17837.  
  17838.  
  17839.  
  17840.  
  17841.  
  17842.                           - 261 -
  17843.  
  17844.  
  17845. o    Only one client at a time can select a ButtonPress
  17846.      event, which is associated with the event mask But-
  17847.      tonPressMask.
  17848.  
  17849. If a client passes both ButtonPressMask and Button-
  17850. ReleaseMask for a specified window, a ButtonPress event in
  17851. that window will automatically grab the mouse until all but-
  17852. tons are released and ButtonRelease events are sent to win-
  17853. dows as described for XGrabPointer.  This ensures that a
  17854. window will see the ButtonRelease event corresponding to the
  17855. ButtonPress event, even though the mouse may have exited the
  17856. window in the meantime.
  17857.  
  17858. If a client passes PointerMotionMask, the X server sends
  17859. MotionNotify events independent of the state of the pointer
  17860. buttons. If, instead, the client passes one or more of
  17861. Button1MotionMask, Button2MotionMask, Button3MotionMask,
  17862. Button4MotionMask, Button5MotionMask, the X server generates
  17863. MotionNotify events only when one or more of the specified
  17864. buttons is depressed.  These are used to request MotionNo-
  17865. tify events only when particular buttons are held down.
  17866.  
  17867. The errors that can be generated by XSelectInput are BadWin-
  17868. dow and BadValue.
  17869.  
  17870. 8.6.  Handling the Output Buffer and the Event Queue
  17871.  
  17872. Xlib provides functions with which you can flush the output
  17873. buffer.  In addition to flushing the output buffer, some of
  17874. these functions also perform additional tasks, such as
  17875. checking the event queue.  The following sections discuss
  17876. how to:
  17877.  
  17878. o    Flush the output buffer
  17879.  
  17880. o    Flush the output buffer and check the event queue
  17881.  
  17882. o    Put an event back on the queue
  17883.  
  17884. 8.6.1.  Flushing the Output Buffer
  17885.  
  17886. The output buffer is an area used by the Xlib library to
  17887. store requests.  The functions described in this section are
  17888. similar in that they flush the output buffer.  That is, all
  17889. requests residing in the output buffer that have not yet
  17890. been sent are transmitted to the X server.  Conversely,
  17891. these functions differ in the additional tasks they might
  17892. perform.  For example, XSync not only flushes the output
  17893. buffer, but it can also discard all events on the event
  17894. queue.  The following paragraphs describe the functions
  17895. XFlush, XSync, and XPending.
  17896.  
  17897.  
  17898. Use XFlush to flush the output buffer.  The definition for
  17899.  
  17900.  
  17901.  
  17902.                      December 18, 1987
  17903.  
  17904.  
  17905.  
  17906.  
  17907.  
  17908.                           - 262 -
  17909.  
  17910.  
  17911. this function is:
  17912.  
  17913. XFlush(display)
  17914.       Display *display;
  17915.  
  17916.  
  17917. display   Specifies the connection to the X server.
  17918.  
  17919. The XFlush function flushes the output buffer.  Most client
  17920. applications need not use this function because the output
  17921. buffer is automatically flushed the next time an event or
  17922. reply is read from the output buffer by a call to XPending,
  17923. XNextEvent, or XWindowEvent.
  17924.  
  17925.  
  17926. Use XSync to flush the output buffer and then wait until all
  17927. requests have been processed.  The definition for this func-
  17928. tion is:
  17929.  
  17930. XSync(display, discard)
  17931.       Display *display;
  17932.       int discard;
  17933.  
  17934.  
  17935. display   Specifies the connection to the X server.
  17936.  
  17937. discard   Specifies whether XSync discards all events on the
  17938.           event queue.  You can pass the value 0 or 1.
  17939.  
  17940. The XSync function flushes the output buffer.  It then waits
  17941. until all events (including error events) have been received
  17942. and processed by the X server.  In addition, this function
  17943. places the events recently processed by the X server on the
  17944. event queue.  For each error event received and processed by
  17945. the X server, XSync calls the client application's XError
  17946. routine.
  17947.  
  17948. Finally, if you passed the value 0 to the discard argument,
  17949. XSync does not discard the events on the queue.  If you
  17950. passed the value 1, this function discards all events on the
  17951. queue, including those events that were on the queue before
  17952. XSync was called.  Client applications use XSync less often
  17953. than they would use XFlush.
  17954.  
  17955.  
  17956. Use XPending to flush the output buffer and return the
  17957. number of events pending.  The definition for this function
  17958. is:
  17959.  
  17960. int XPending(display)
  17961.       Display *display;
  17962.  
  17963.  
  17964.  
  17965.  
  17966.  
  17967.  
  17968.                      December 18, 1987
  17969.  
  17970.  
  17971.  
  17972.  
  17973.  
  17974.                           - 263 -
  17975.  
  17976.  
  17977. display   Specifies the connection to the X server.
  17978.  
  17979. The XPending function flushes the output buffer.  It then
  17980. returns the number of events received from the X server but
  17981. not yet removed from the event queue.  (You remove events
  17982. from the queue by calling XNextEvent or XWindowEvent.)  You
  17983. should call XPending before blocking or waiting for new
  17984. events (for example, calling the select system call on a
  17985. UNIX-based system).  The events you are waiting for may have
  17986. already arrived and be sitting in Xlib's queue.
  17987.  
  17988. 8.6.2.  Flushing the Output Buffer and Checking the Event
  17989. Queue
  17990.  
  17991. As discussed in the previous section, the output buffer is
  17992. an area used by the X server to store requests.  The func-
  17993. tions described in this section are similar in that they all
  17994. flush the output buffer and then check the event queue to
  17995. see if the next event on the queue is the one wanted by the
  17996. client.  Conversely, these functions differ in what they do
  17997. with the event after checking it on the event queue.  These
  17998. functions also differ in whether they pass a predicate pro-
  17999. cedure.  The functions XNextEvent and XPeekEvent do not take
  18000. a predicate procedure and are discussed first.  Subsequent
  18001. paragraphs describe the predicate procedure and the func-
  18002. tions that pass it:  XIfEvent, XCheckIfEvent, and XPeekI-
  18003. fEvent.
  18004.  
  18005.  
  18006. Use XNextEvent to flush the output buffer, copy the next
  18007. event, and then remove it from the event queue.  The defini-
  18008. tion for this function is:
  18009.  
  18010. XNextEvent(display, event_return)
  18011.       Display *display;
  18012.       XEvent *event_return;
  18013.  
  18014.  
  18015. display   Specifies the connection to the X server.
  18016.  
  18017. event_returnThe XNextEvent function copies the event's asso-
  18018.           ciated structure into this client-supplied struc-
  18019.           ture.
  18020.  
  18021. The XNextEvent function flushes the output buffer.  If the
  18022. event queue is empty, XNextEvent blocks until an event is
  18023. received.  It then removes an event from the head of the
  18024. queue and copies its associated structure into a client-
  18025. supplied XEvent structure.  For example, if a CreateNotify
  18026. event is at the head of the queue, this function removes it
  18027. and then copies the structure XCreateWindowEvent into
  18028. XEvent.
  18029.  
  18030.  
  18031.  
  18032.  
  18033.  
  18034.                      December 18, 1987
  18035.  
  18036.  
  18037.  
  18038.  
  18039.  
  18040.                           - 264 -
  18041.  
  18042.  
  18043. Use XPeekEvent to flush the output buffer and peek at the
  18044. event queue.  The definition for this function is:
  18045.  
  18046. XPeekEvent(display, event_return)
  18047.       Display *display;
  18048.       XEvent *event_return;
  18049.  
  18050.  
  18051. display   Specifies the connection to the X server.
  18052.  
  18053. event_returnThe XPeekEvent function copies the event's asso-
  18054.           ciated structure into this client-supplied struc-
  18055.           ture.
  18056.  
  18057. The XPeekEvent function flushes the output buffer.  If the
  18058. queue is empty, XPeekEvent blocks until an event is
  18059. received.  It then peeks at an event from the head of the
  18060. queue and copies its associated structure into the client-
  18061. supplied XEvent structure without removing it from the event
  18062. queue.  For example, if a CreateNotify event is at the head
  18063. of the queue, this function peeks at it but does not remove
  18064. it and then copies the structure XCreateWindowEvent into
  18065. XEvent.  You can use the QLength macro to determine if there
  18066. are any events to peek at.
  18067.  
  18068.  
  18069. Each of the functions discussed in the following paragraphs
  18070. requires you to pass a predicate procedure that determines
  18071. if the event matches the one specified in the corresponding
  18072. function.  The predicate procedure and its associated argu-
  18073. ments are:
  18074.  
  18075. Bool (*predicate)(display, event, args)
  18076.      Display *display;
  18077.      XEvent *event;
  18078.      char *args;
  18079.  
  18080.  
  18081. display   Specifies the connection to the X server.
  18082.  
  18083. event     Specifies a pointer to the structure XEvent.  This
  18084.           structure is a union of the individual structures
  18085.           declared for each event type.
  18086.  
  18087. args      Specifies the arguments passed in from the
  18088.           XIfEvent, XCheckIfEvent, or XPeekIfEvent function.
  18089.  
  18090. The predicate procedure is called once for each event in the
  18091. queue until it finds a match between the event in the queue
  18092. and the event specified by the corresponding function.
  18093. After finding a match, the predicate procedure must return
  18094. True or False if it did not find a match.
  18095.  
  18096.  
  18097.  
  18098.  
  18099.  
  18100.                      December 18, 1987
  18101.  
  18102.  
  18103.  
  18104.  
  18105.  
  18106.                           - 265 -
  18107.  
  18108.  
  18109. Use XIfEvent to flush the output buffer, check the event
  18110. queue for the specified event, and, if the events match,
  18111. remove the event from the queue.  The definition for this
  18112. function is:
  18113.  
  18114. XIfEvent(display, event_return, predicate, arg)
  18115.       Display *display;
  18116.       XEvent *event_return;
  18117.       Bool (*predicate)();
  18118.       char *arg;
  18119.  
  18120.  
  18121. display   Specifies the connection to the X server.
  18122.  
  18123. event_returnThe XIfEvent function copies the matched event's
  18124.           associated structure into this client-supplied
  18125.           structure.
  18126.  
  18127. predicate Specifies the procedure that is to be called to
  18128.           determine if the next event in the queue matches
  18129.           the one specified by the event argument.
  18130.  
  18131. arg       Specifies the user-supplied argument that will be
  18132.           passed to the predicate procedure.
  18133.  
  18134. The XIfEvent function flushes the output buffer.  It com-
  18135. pletes only when the specified predicate procedure returns a
  18136. nonzero (true) for an event, which indicates an event on the
  18137. queue matches the specified event.  This predicate procedure
  18138. is also called each time an event is added to the queue.
  18139. XIfEvent removes the event from the queue and, when it
  18140. returns, copies the structure into the client-supplied
  18141. XEvent structure.
  18142.  
  18143.  
  18144. Use XCheckIfEvent to flush the output buffer and check the
  18145. event queue for the specified event without blocking. The
  18146. definition for this function is:
  18147.  
  18148. Bool XCheckIfEvent(display, event_return, predicate, arg)
  18149.       Display *display;
  18150.       XEvent *event_return;
  18151.       Bool (*predicate)();
  18152.       char *arg;
  18153.  
  18154.  
  18155. display   Specifies the connection to the X server.
  18156.  
  18157. event_returnThe XCheckIfEvent function copies the matched
  18158.           event's associated structure into this client-
  18159.           supplied structure.
  18160.  
  18161.  
  18162.  
  18163.  
  18164.  
  18165.  
  18166.                      December 18, 1987
  18167.  
  18168.  
  18169.  
  18170.  
  18171.  
  18172.                           - 266 -
  18173.  
  18174.  
  18175. predicate Specifies the procedure that is to be called to
  18176.           determine if the next event in the queue matches
  18177.           the one specified by the event argument.
  18178.  
  18179. arg       Specifies the user-supplied argument that will be
  18180.           passed to the predicate procedure.
  18181.  
  18182. The XCheckIfEvent function flushes the output buffer.  It
  18183. completes only when the specified predicate procedure
  18184. returns True for the next event in the queue that matches
  18185. the specified event. If the predicate procedure finds a
  18186. match, XCheckIfEvent copies the matched event into the
  18187. client-supplied XEvent structure and returns True (This
  18188. event is removed from the queue.)  If the predicate pro-
  18189. cedure finds no match, XCheckIfEvent returns False.  All
  18190. earlier events stored in the queue are not discarded.
  18191.  
  18192.  
  18193. Use XPeekIfEvent to flush the output buffer, check the event
  18194. queue for the specified event, but not remove the event from
  18195. the queue.  The definition for this function is:
  18196.  
  18197. XPeekIfEvent(display, event_return, predicate, arg)
  18198.       Display *display;
  18199.       XEvent *event_return;
  18200.       Bool (*predicate)();
  18201.       char *arg;
  18202.  
  18203.  
  18204. display   Specifies the connection to the X server.
  18205.  
  18206. event_returnThe XPeekIfEvent function copies the matched
  18207.           event's associated structure into this client-
  18208.           supplied structure.
  18209.  
  18210. predicate Specifies the procedure that is to be called to
  18211.           determine if the next event in the queue matches
  18212.           the one specified by the event argument.
  18213.  
  18214. arg       Specifies the user-supplied argument that will be
  18215.           passed to the predicate procedure.
  18216.  
  18217. The XPeekIfEvent function flushes the output buffer.  It
  18218. returns only when the specified predicate procedure returns
  18219. a nonzero (true) for the next event in the queue that
  18220. matches the specified event. This predicate procedure is
  18221. called each time an event is added to the queue.  After the
  18222. predicate procedure finds a match, XPeekIfEvent copies the
  18223. matched event into the client-supplied XEvent structure
  18224. without removing the event from the queue.
  18225.  
  18226.  
  18227.  
  18228.  
  18229.  
  18230.  
  18231.  
  18232.                      December 18, 1987
  18233.  
  18234.  
  18235.  
  18236.  
  18237.  
  18238.                           - 267 -
  18239.  
  18240.  
  18241. 8.6.3.  Putting an Event Back onto the Queue
  18242.  
  18243. Use XPutBackEvent to push an event back to the top of the
  18244. event queue.  The definition for this function is:
  18245.  
  18246. XPutBackEvent(display, event)
  18247.       Display *display;
  18248.       XEvent *event;
  18249.  
  18250.  
  18251. display   Specifies the connection to the X server.
  18252.  
  18253. event     Specifies a pointer to the XEvent structure.  This
  18254.           structure is a union of the individual structures
  18255.           declared for each event type.
  18256.  
  18257. The XPutBackEvent function pushes an event back onto the
  18258. head of the current display's event queue.  This can be use-
  18259. ful if you have read an event and then decide that you would
  18260. rather deal with it later.  There is no limit to how many
  18261. times in succession you can call XPutBackEvent.
  18262.  
  18263. 8.7.  Selecting Events from the Event Queue
  18264.  
  18265. The functions described in this section are similar in that
  18266. they all flush the output buffer. That is, all requests
  18267. residing in the output buffer that have not yet been sent
  18268. are transmitted to the client application.  These functions
  18269. also allow you to select event types.  By allowing you to
  18270. select event types, you can process events out of order.
  18271. Conversely, these functions differ in the way they process
  18272. these events.  Yet, several require you to pass an event
  18273. mask. See Section 8.3. for a discussion of the valid event
  18274. mask names.
  18275.  
  18276.  
  18277. Use XWindowEvent to remove the next matched event for the
  18278. specified window.  The definition for this function is:
  18279.  
  18280. XWindowEvent(display, w, event_mask, event_return)
  18281.       Display *display;
  18282.       Window w;
  18283.       long event_mask;
  18284.       XEvent *event_return;
  18285.  
  18286.  
  18287. display   Specifies the connection to the X server.
  18288.  
  18289. w         Specifies the window ID.  This is the window whose
  18290.           next matched event you want to remove.
  18291.  
  18292. event_maskSpecifies the event mask.  This mask is the bit-
  18293.           wise inclusive OR of one or more of the valid
  18294.           event mask bits.
  18295.  
  18296.  
  18297.  
  18298.                      December 18, 1987
  18299.  
  18300.  
  18301.  
  18302.  
  18303.  
  18304.                           - 268 -
  18305.  
  18306.  
  18307. event_returnThe XWindowEvent function copies the matched
  18308.           event's associated structure into this client-
  18309.           supplied structure.
  18310.  
  18311. The XWindowEvent function flushes the output buffer.  It
  18312. then searches the event queue for the events associated with
  18313. the specified window.  XWindowEvent removes the next event
  18314. in the queue that matches both the window and the event mask
  18315. that you passed.  It then copies the event's associated
  18316. structure into the client-supplied XEvent structure.  All
  18317. earlier events stored in the queue are not discarded.  If
  18318. the event you requested is not in the queue, XWindowEvent
  18319. blocks until one is received.
  18320.  
  18321.  
  18322. Use XCheckWindowEvent to remove the next event that matches
  18323. both the passed window and the passed mask. This function is
  18324. very similar to XWindowEvent, except it does not block,  and
  18325. it returns a zero (0) or one (1) value.  The definition for
  18326. this function is:
  18327.  
  18328. Bool XCheckWindowEvent(display, w, event_mask, event_return)
  18329.       Display *display;
  18330.       Window w;
  18331.       int event_mask;
  18332.       XEvent *event_return;
  18333.  
  18334.  
  18335. display   Specifies the connection to the X server.
  18336.  
  18337. w         Specifies the window ID.  This is the window whose
  18338.           next matched event you want to remove.
  18339.  
  18340. event_maskSpecifies the event mask.  This mask is the bit-
  18341.           wise inclusive OR of one or more of the valid
  18342.           event mask bits.
  18343.  
  18344. event_returnThe XCheckWindowEvent function copies the
  18345.           matched event's associated structure into this
  18346.           client-supplied structure.
  18347.  
  18348. The XCheckWindowEvent function flushes the output buffer.
  18349. It then searches the event queue for the events associated
  18350. with the specified window.  XCheckWindowEvent removes the
  18351. next event in the queue that matches both the window and the
  18352. event mask that you passed.  It then copies the event's
  18353. associated structure into the client-supplied XEvent struc-
  18354. ture and returns True.  All earlier events stored in the
  18355. queue are not discarded.  If the event you requested is not
  18356. in the queue, XCheckWindowEvent immediately returns False.
  18357.  
  18358.  
  18359. Use XMaskEvent to remove the next event in the queue that
  18360. matches the passed mask.  The definition for this function
  18361.  
  18362.  
  18363.  
  18364.                      December 18, 1987
  18365.  
  18366.  
  18367.  
  18368.  
  18369.  
  18370.                           - 269 -
  18371.  
  18372.  
  18373. is:
  18374.  
  18375. XMaskEvent(display, event_mask, event_return)
  18376.       Display *display;
  18377.       unsigned long event_mask;
  18378.       XEvent *event_return;
  18379.  
  18380.  
  18381. display   Specifies the connection to the X server.
  18382.  
  18383. event_maskSpecifies the event mask.  This mask is the bit-
  18384.           wise inclusive OR of one or more of the valid
  18385.           event mask bits.
  18386.  
  18387. event_returnThe XMaskEvent function copies the matched
  18388.           event's associated structure into this client-
  18389.           supplied structure.
  18390.  
  18391. The XMaskEvent function flushes the output buffer.  It then
  18392. searches the event queue for the events associated with the
  18393. specified mask.  XMaskEvent removes the next event in the
  18394. queue that matches the event mask that you passed.  It then
  18395. copies the event's associated structure into the client-
  18396. supplied XEvent structure.  All earlier events stored in the
  18397. queue are not discarded.  If the event you requested is not
  18398. in the queue, XMaskEvent blocks until one is received.
  18399.  
  18400.  
  18401. Use XCheckMaskEvent to remove the next event that matches
  18402. the passed mask.  This function is exactly the same as
  18403. XMaskEvent except that it does not block and it returns a 0
  18404. or 1 value.  The definition for this function is:
  18405.  
  18406. Bool XCheckMaskEvent(display, event_mask, event_return)
  18407.       Display *display;
  18408.       unsigned long event_mask;
  18409.       XEvent *event_return;
  18410.  
  18411.  
  18412. display   Specifies the connection to the X server.
  18413.  
  18414. event_maskSpecifies the event mask.  This mask is the bit-
  18415.           wise inclusive OR of one or more of the valid
  18416.           event mask bits.
  18417.  
  18418. event_returnThe XCheckMaskEvent function copies the matched
  18419.           event's associated structure into this client-
  18420.           supplied structure.
  18421.  
  18422. The XCheckMaskEvent function flushes the output buffer.  It
  18423. then searches the event queue for the events associated with
  18424. the specified mask.  XCheckMaskEvent removes the next event
  18425. in the queue that matches the event mask that you passed.
  18426. It then copies the event's associated structure into the
  18427.  
  18428.  
  18429.  
  18430.                      December 18, 1987
  18431.  
  18432.  
  18433.  
  18434.  
  18435.  
  18436.                           - 270 -
  18437.  
  18438.  
  18439. client-supplied XEvent structure and returns True.  All ear-
  18440. lier events stored in the queue are not discarded.  If the
  18441. event you requested is not in the queue, XCheckMaskEvent
  18442. immediately returns False.
  18443.  
  18444.  
  18445. Use XCheckTypedEvent to return the next event in the queue
  18446. that matches an event type.  The definition for this func-
  18447. tion is:
  18448.  
  18449. int XCheckTypedEvent(display, event_type, event_return)
  18450.       Display *display;
  18451.       int event_type;
  18452.       XEvent *event_return;
  18453.  
  18454.  
  18455. display   Specifies the connection to the X server.
  18456.  
  18457. event_typeSpecifies the event type to be compared.
  18458.  
  18459.  
  18460. event_returnThe XCheckTypedEvent function copies the matched
  18461.           event's associated structure into this client-
  18462.           supplied structure.
  18463.  
  18464. The XCheckTypedEvent function flushes the output buffer,
  18465. searches the event queue for the specified event type, and,
  18466. if there is a match, returns its associated event structure
  18467. to the specified XEvent structure. Note that events earlier
  18468. in the queue are not discarded.  In addition, XCheck-
  18469. TypedEvent returns True if the event is found and False if
  18470. the event is not found.
  18471.  
  18472.  
  18473. Use XCheckTypedWindowEvent to return the next matched event
  18474. in the queue for the specified window.  The definition for
  18475. this function is:
  18476.  
  18477. int XCheckTypedWindowEvent(display, w, event_type, event_return)
  18478.       Display *display;
  18479.       Window w;
  18480.       int event_type;
  18481.       XEvent *event_return;
  18482.  
  18483.  
  18484. display   Specifies the connection to the X server.
  18485.  
  18486. w         Specifies the window ID.
  18487.  
  18488. event_typeSpecifies the event type to be compared.
  18489.  
  18490.  
  18491.  
  18492.  
  18493.  
  18494.  
  18495.  
  18496.                      December 18, 1987
  18497.  
  18498.  
  18499.  
  18500.  
  18501.  
  18502.                           - 271 -
  18503.  
  18504.  
  18505. event_returnThe XCheckTypedWindowEvent function copies the
  18506.           matched event's associated structure into this
  18507.           client-supplied structure.
  18508.  
  18509. The XCheckTypedWindowEvent function flushes the output
  18510. buffer and searches the event queue for the events associ-
  18511. ated with the specified window.  XCheckTypedWindowEvent
  18512. returns the next event that matches the window and the
  18513. specified event type to the specified XEvent structure.
  18514. Note that events earlier in the queue are not discarded.  In
  18515. addition, XCheckTypedWindowEvent returns True if the event
  18516. is found and False if the event is not found.
  18517.  
  18518. 8.8.  Sending and Getting Events
  18519.  
  18520. This section discusses how to send events and how to obtain
  18521. motion events.  Use XSendEvent to send an event to a speci-
  18522. fied window. This function is often used in selection pro-
  18523. cessing.  For example, the owner of a selection should use
  18524. XSendEvent to send a SelectionNotify event to a requestor
  18525. when a selection has been converted and stored as a pro-
  18526. perty.  The definition for this function is:
  18527.  
  18528. XSendEvent(display, w, propagate, event_mask, event_send)
  18529.       Display *display;
  18530.       Window w;
  18531.       Bool propagate;
  18532.       unsigned long event_mask;
  18533.       XEvent *event_send;
  18534.  
  18535.  
  18536. display   Specifies the connection to the X server.
  18537.  
  18538. w         Specifies the window ID.  This is the window
  18539.           interested in the event, and is referred to as the
  18540.           destination window.  You can pass the window ID or
  18541.           the constants PointerWindow or InputFocus.
  18542.  
  18543. propagate Specifies a boolean value that is either the con-
  18544.           stant True or False.
  18545.  
  18546. event_maskSpecifies the event mask.  This mask is the bit-
  18547.           wise inclusive OR of one or more of the valid
  18548.           event mask bits.
  18549.  
  18550. event_sendSpecifies a pointer to the event that is to be
  18551.           sent.
  18552.  
  18553. The XSendEvent function identifies the destination window,
  18554. determines which clients should receive the specified
  18555. events, and ignores any active grabs.  This function
  18556. requires you to pass an event mask.  See Section 8.3 for a
  18557. discussion of the valid event mask names.  This function
  18558. uses the w argument to identify the destination window as
  18559.  
  18560.  
  18561.  
  18562.                      December 18, 1987
  18563.  
  18564.  
  18565.  
  18566.  
  18567.  
  18568.                           - 272 -
  18569.  
  18570.  
  18571. follows:
  18572.  
  18573. o    If you pass PointerWindow to w, the destination window
  18574.      is the window that contains the pointer.
  18575.  
  18576. o    If you pass InputFocus to w, and if the focus window
  18577.      contains the pointer, the destination window is the
  18578.      window that contains the pointer. If the focus window
  18579.      does not contain the pointer, the destination window is
  18580.      the focus window.
  18581.  
  18582. To determine which clients should receive the specified
  18583. events, XSendEvent uses the propagate argument as follows:
  18584.  
  18585. o    If propagate is False, the event is sent to every
  18586.      client selecting on destination any of the event types
  18587.      in the event_mask argument.
  18588.  
  18589. o    If propagate is True, and no clients have selected on
  18590.      destination any of the event types in event-mask, the
  18591.      destination is replaced with the closest ancestor of
  18592.      destination for which some client has selected a type
  18593.      in event-mask and for which no intervening window has
  18594.      that type in its do_not_propagate_mask. If no such win-
  18595.      dow exists or if the window is an ancestor of the focus
  18596.      window and InputFocus was originally specified as the
  18597.      destination, the event is not sent to any clients.
  18598.      Otherwise, the event is reported to every client
  18599.      selecting on the final destination any of the types
  18600.      specified in event_mask.
  18601.  
  18602. The events in the XEvent structure must be one of the core
  18603. events or one of the events defined by a loaded extension,
  18604. so that the X server can correctly byte swap the contents as
  18605. necessary. The contents of the event are otherwise unaltered
  18606. and unchecked by the X server except to force on the most
  18607. significant bit of the event code.
  18608.  
  18609. Many X server implementations will maintain a more precise
  18610. history of mouse motion between event notification.  The
  18611. mouse position at each mouse hardware interrupt may be
  18612. stored into a buffer for later retrieval.  This is called
  18613. the motion history buffer.  For example, a few applications,
  18614. best exemplified by paint programs, want to have a precise
  18615. history of where the mouse traveled. However, this is highly
  18616. excessive for most applications.
  18617.  
  18618. The errors that can be generated by XSendEvent are BadWindow
  18619. and BadValue.
  18620.  
  18621. 8.9.  Getting Pointer Motion Events
  18622.  
  18623.  
  18624. Use XGetMotionEvents to return motion events for a specified
  18625.  
  18626.  
  18627.  
  18628.                      December 18, 1987
  18629.  
  18630.  
  18631.  
  18632.  
  18633.  
  18634.                           - 273 -
  18635.  
  18636.  
  18637. window and the number of these events in the motion history
  18638. buffer.  The definition for this function is:
  18639.  
  18640. XTimeCoord *XGetMotionEvents(display, w, start, stop, nevents_return)
  18641.       Display *display;
  18642.       Window w;
  18643.       Time start, stop;
  18644.       int *nevents_return;
  18645.  
  18646.  
  18647. display   Specifies the connection to the X server.
  18648.  
  18649. w         Specifies the window ID.  This is the window whose
  18650.           associated pointer motion events you want to
  18651.           retrieve.
  18652.  
  18653. start
  18654. stop      Specify the time interval in which the events are
  18655.           returned from the motion history buffer.  You can
  18656.           pass a time stamp, expressed in milliseconds, or
  18657.           the constant CurrentTime.  If the stop time is in
  18658.           the future, it is equivalent to specifying
  18659.           CurrentTime.
  18660.  
  18661. nevents_returnReturns the number of events from the motion
  18662.           history buffer.
  18663.  
  18664. The XGetMotionEvents function returns all events in the
  18665. motion history buffer that fall between the specified start
  18666. and stop times inclusive and that have coordinates that lie
  18667. within (including borders) the specified window at its
  18668. present placement.  If the start time is later than the stop
  18669. time or if the start time is in the future, no events are
  18670. returned.  The return type for this function is a structure
  18671. defined as follows:
  18672.  
  18673. typedef struct {
  18674.           Time time;
  18675.           unsigned short x, y;
  18676. } XTimeCoord;
  18677.  
  18678.  
  18679. The time member is set to the time, in milliseconds. The x
  18680. and y members are set to the coordinates of the pointer and
  18681. are reported relative to the origin of the specified window.
  18682. You should use XFree to free the data returned from this
  18683. call.  (See Section 2.4 for further information.)
  18684.  
  18685. The error that can be generated by XGetMotionEvents is
  18686. BadWindow.
  18687.  
  18688.  
  18689.  
  18690.  
  18691.  
  18692.  
  18693.  
  18694.                      December 18, 1987
  18695.  
  18696.  
  18697.  
  18698.  
  18699.  
  18700.                           - 274 -
  18701.  
  18702.  
  18703. 8.10.  Handling Error Events
  18704.  
  18705. Xlib provides functions with which you can:
  18706.  
  18707. o    Enable or disable synchronization
  18708.  
  18709. o    Use the default error handlers
  18710.  
  18711. The following sections discuss the functions associated with
  18712. these tasks.  Error Handling
  18713.  
  18714. 8.10.1.  Enabling or Disabling Synchronization
  18715.  
  18716. When debugging X applications, it can be very convenient to
  18717. require the library to behave synchronously, so that errors
  18718. are reported at the time they occur.  The routine below
  18719. allows you to disable or enable synchronous behavior.  Note
  18720. that graphics may occur dramatically slower when enabled (30
  18721. or more times slower).  On UNIX-based systems, there is also
  18722. a global variable _Xdebug that if set to nonzero before
  18723. starting a program under a debugger will force synchronous
  18724. library behavior.
  18725.  
  18726. Use XSynchronize to enable or disable synchronization.  The
  18727. definition for this function is:
  18728.  
  18729. int (*XSynchronize(display, onoff))()
  18730.       Display *display;
  18731.       int onoff;
  18732.  
  18733.  
  18734. display   Specifies the connection to the X server.
  18735.  
  18736. onoff     Specifies whether to enable or disable synchroni-
  18737.           zation.  Possible values you can pass are 0 (dis-
  18738.           able synchronization) or nonzero (enable synchron-
  18739.           ization).
  18740.  
  18741. The XSynchronize function returns the previous after func-
  18742. tion.  If onoff is nonzero, XSynchronize turns on synchro-
  18743. nous behavior.  A value of zero (0) resets the state to off
  18744. (disable synchronous behavior).
  18745.  
  18746. After completing their work, all Xlib functions that gen-
  18747. erate protocol requests call what is known as a previous
  18748. after function.  XSetAfterFunction sets which function is to
  18749. be called.  The definition for this function is:
  18750.  
  18751. int (*XSetAfterFunction(display, proc))()
  18752.       Display *display;
  18753.       int (*proc)();
  18754.  
  18755.  
  18756.  
  18757.  
  18758.  
  18759.  
  18760.                      December 18, 1987
  18761.  
  18762.  
  18763.  
  18764.  
  18765.  
  18766.                           - 275 -
  18767.  
  18768.  
  18769. display   Specifies the connection to the X server.
  18770.  
  18771. proc      Specifies the function to be called after an Xlib
  18772.           function that generates a protocol request com-
  18773.           pletes its work.
  18774.  
  18775. The specified proc will be called with only a display
  18776. pointer.
  18777.  
  18778. 8.10.2.  Using the Default Error Handlers
  18779.  
  18780. There are two default error handlers in the library, one to
  18781. handle typically fatal conditions (for example, the connec-
  18782. tion to a display server dying due to a machine crash), and
  18783. one to handle error events from the X server.  These error
  18784. handlers can be changed to user-supplied routines if you
  18785. prefer your own error handling and can be changed as often
  18786. as you like.  If either of these routines are passed a NULL
  18787. pointer, it will reinvoke the default handler.  The default
  18788. action of the supplied routine is to print an explanatory
  18789. message and exit.  This section discusses:  XSetEr-
  18790. rorHandler, XGetErrorText, XGetErrorDatabaseText, XDisplay-
  18791. Name, and XSetIOErrorHandler.
  18792.  
  18793.  
  18794. Use XSetErrorHandler to handle error events.  The definition
  18795. for this function is:
  18796.  
  18797. XSetErrorHandler(handler)
  18798.       int (*handler)(Display *, XErrorEvent *)
  18799.  
  18800.  
  18801. handler   Specifies the program's supplied error handler.
  18802.  
  18803. The program's supplied error hander will be called by Xlib
  18804. whenever an XError event is received.  This is not assumed
  18805. to be a fatal condition. It is acceptable for this procedure
  18806. to return.  However, the error handler should not perform
  18807. any operations (directly or indirectly) on the display.  The
  18808. fields of the XErrorEvent structure passed to XError should
  18809. be interpreted as follows:
  18810.  
  18811. typedef struct {
  18812.      int type
  18813.      Display *display;   /* Display the event was read from */
  18814.      int serial;         /* serial number of failed request */
  18815.      char error_code;    /* error code of failed request */
  18816.      char request_code;  /* Major op-code of failed request */
  18817.      char minor_code;    /* Minor op-code of failed request */
  18818.      XID resourceid;     /* resource id */
  18819. } XErrorEvent;
  18820.  
  18821.  
  18822. The serial member is the number of requests starting from
  18823.  
  18824.  
  18825.  
  18826.                      December 18, 1987
  18827.  
  18828.  
  18829.  
  18830.  
  18831.  
  18832.                           - 276 -
  18833.  
  18834.  
  18835. one sent over the network connection since it was opened. It
  18836. is the number that was the value of the request sequence
  18837. number immediately after the failing call was made. The
  18838. request_code member is a protocol representation of the name
  18839. of the procedure that failed and are defined in <X11/X.h>.
  18840. The following error codes can be returned by the functions
  18841. described in this chapter:
  18842.  
  18843.  
  18844. ____________________________________________________________
  18845. Error Code                        Description
  18846. ____________________________________________________________
  18847. BadAccess
  18848.                     A client attempted to grab a key/button
  18849.                     combination already grabbed by another
  18850.                     client.
  18851.                     A client attempted to free a color map
  18852.                     entry that it did not already allocate.
  18853.                     A client attempted to store into a
  18854.                     read-only color map entry.
  18855.                     A client attempted to modify the access
  18856.                     control list from other than the local
  18857.                     (or otherwise authorized) host.
  18858.                     A client attempted to select an event
  18859.                     type that another client has already
  18860.                     selected, and, that at most, one client
  18861.                     can select at a time.
  18862.  
  18863.  
  18864.  
  18865.  
  18866.  
  18867.  
  18868.  
  18869.  
  18870.  
  18871.  
  18872.  
  18873.  
  18874.  
  18875.  
  18876.  
  18877.  
  18878. BadAlloc
  18879.                     The server failed to allocate the
  18880.                     requested resource or server memory.
  18881.  
  18882.  
  18883. BadAtom
  18884.                     A value for an Atom argument does not
  18885.                     name a defined Atom.
  18886.  
  18887.  
  18888. BadColor
  18889.                     A value for a Colormap argument does not
  18890.                     name a defined Colormap.
  18891.  
  18892.  
  18893. BadCursor
  18894.                     A value for a Cursor argument does not
  18895.                     name a defined Cursor.
  18896.  
  18897.  
  18898. BadDrawable
  18899.                     A value for a Drawable argument does not
  18900.                     name a defined Window or Pixmap.
  18901.  
  18902.  
  18903. BadFont
  18904.                     A value for a Font or GContext argument
  18905.                     does not name a defined Font.
  18906.  
  18907.  
  18908. BadGC
  18909.                     A value for a GContext argument does not
  18910.                     name a defined GContext.
  18911.  
  18912.  
  18913. BadIDChoice
  18914.                     The value chosen for a resource identif-
  18915.                     ier is either not included in the range
  18916.                     assigned to the client or is already in
  18917.                     use.  Under normal circumstances this
  18918.                     cannot occur and should be considered a
  18919.                     server or X Library error.
  18920.  
  18921.  
  18922.  
  18923.  
  18924.  
  18925.  
  18926. BadImplementation
  18927.  
  18928.  
  18929.  
  18930.                      December 18, 1987
  18931.  
  18932.  
  18933.  
  18934.  
  18935.  
  18936.                           - 277 -
  18937.  
  18938.  
  18939. ____________________________________________________________
  18940. Error Code                        Description
  18941. ____________________________________________________________
  18942.  
  18943.  
  18944.  
  18945.  
  18946.  
  18947.  
  18948.  
  18949.  
  18950.  
  18951.  
  18952.  
  18953.  
  18954.  
  18955.  
  18956.  
  18957.  
  18958.  
  18959.  
  18960.  
  18961.  
  18962.  
  18963.  
  18964.  
  18965.  
  18966.  
  18967.  
  18968.  
  18969.  
  18970.  
  18971.  
  18972.  
  18973.  
  18974.  
  18975.  
  18976.  
  18977.  
  18978.  
  18979.  
  18980.  
  18981.  
  18982.  
  18983.  
  18984.  
  18985.  
  18986.  
  18987.  
  18988.  
  18989.  
  18990.  
  18991.                     The server does not implement some
  18992.  
  18993.  
  18994.  
  18995.                      December 18, 1987
  18996.  
  18997.  
  18998.  
  18999.  
  19000.  
  19001.                           - 278 -
  19002.  
  19003.  
  19004. ____________________________________________________________
  19005. Error Code                        Description
  19006. ____________________________________________________________
  19007.                     aspect of the request.  A server that
  19008.                     generates this error for a core request
  19009.                     is deficient.  As such, this error is
  19010.                     not listed for any of the requests.
  19011.                     However, clients should be prepared to
  19012.                     receive such errors and either handle or
  19013.                     discard them.
  19014.  
  19015.  
  19016.  
  19017.  
  19018.  
  19019.  
  19020.  
  19021.  
  19022.  
  19023.  
  19024.  
  19025.  
  19026.  
  19027.  
  19028.  
  19029.  
  19030.  
  19031.  
  19032.  
  19033.  
  19034.  
  19035.  
  19036.  
  19037.  
  19038.  
  19039.  
  19040.  
  19041.  
  19042.  
  19043.  
  19044.  
  19045.  
  19046.  
  19047.  
  19048.  
  19049.  
  19050.  
  19051.  
  19052.  
  19053.  
  19054.  
  19055.  
  19056.  
  19057.  
  19058.  
  19059.  
  19060.                      December 18, 1987
  19061.  
  19062.  
  19063.  
  19064.  
  19065.  
  19066.                           - 279 -
  19067.  
  19068.  
  19069. ____________________________________________________________
  19070. Error Code                        Description
  19071. ____________________________________________________________
  19072.  
  19073.  
  19074.  
  19075.  
  19076.  
  19077.  
  19078.  
  19079.  
  19080.  
  19081.  
  19082.  
  19083.  
  19084.  
  19085.  
  19086.  
  19087.  
  19088.  
  19089.  
  19090.  
  19091.  
  19092.  
  19093.  
  19094.  
  19095.  
  19096.  
  19097.  
  19098.  
  19099.  
  19100.  
  19101.  
  19102.  
  19103.  
  19104.  
  19105.  
  19106.  
  19107.  
  19108.  
  19109.  
  19110.  
  19111.  
  19112.  
  19113.  
  19114.  
  19115.  
  19116.  
  19117.  
  19118.  
  19119.  
  19120.  
  19121.  
  19122.  
  19123.  
  19124.  
  19125.                      December 18, 1987
  19126.  
  19127.  
  19128.  
  19129.  
  19130.  
  19131.                           - 280 -
  19132.  
  19133.  
  19134. ____________________________________________________________
  19135. Error Code                        Description
  19136. ____________________________________________________________
  19137. BadLength
  19138.                     The length of a request is shorter or
  19139.                     longer than that minimally required to
  19140.                     contain the arguments.  This usually
  19141.                     means an internal Xlib error.
  19142.  
  19143.  
  19144.  
  19145.  
  19146. BadMatch
  19147.                     In a graphics request, the root and
  19148.                     depth of the GC does not match that of
  19149.                     the drawable.
  19150.                     An InputOnly window is used as a Draw-
  19151.                     able.
  19152.                     Some argument or pair of arguments has
  19153.                     the correct type and range but fails to
  19154.                     match in some other way required by the
  19155.                     request.
  19156.                     An InputOnly window locks this attri-
  19157.                     bute.
  19158.                     The values do not exist for an InputOnly
  19159.                     window.
  19160.  
  19161.  
  19162.  
  19163.  
  19164.  
  19165.  
  19166.  
  19167.  
  19168.  
  19169.  
  19170.  
  19171.  
  19172.  
  19173.  
  19174.  
  19175. BadName
  19176.                     A font or color of the specified name
  19177.                     does not exist.
  19178.  
  19179.  
  19180. BadPixmap
  19181.                     A value for a Pixmap argument does not
  19182.                     name a defined Pixmap.
  19183.  
  19184.  
  19185. BadRequest
  19186.                     The major or minor opcode does not
  19187.                     specify a valid request.
  19188.  
  19189.  
  19190. BadValue
  19191.                     Some numeric value falls outside the
  19192.                     range of values accepted by the request.
  19193.                     Unless a specific range is specified for
  19194.                     an argument, the full range defined by
  19195.                     the argument's type is accepted.  Any
  19196.                     argument defined as a set of alterna-
  19197.                     tives can generate this error.
  19198.  
  19199.  
  19200.  
  19201.  
  19202.  
  19203.  
  19204.  
  19205. BadWindow
  19206.                     A value for a Window argument does not
  19207.                     name a defined Window.
  19208.  
  19209.  
  19210. ____________________________________________________________
  19211.  
  19212.  
  19213.                             Note
  19214.  
  19215.      The BadAtom, BadColor, BadCursor, BadDrawable,
  19216.      BadFont, BadGC, BadPixmap, and BadWindow errors
  19217.      are also used when the argument type is extended
  19218.      by union with a set of fixed alternatives, for
  19219.      example, <Window or PointerRoot or None.
  19220.  
  19221.  
  19222.  
  19223.  
  19224.  
  19225.  
  19226.                      December 18, 1987
  19227.  
  19228.  
  19229.  
  19230.  
  19231.  
  19232.                           - 281 -
  19233.  
  19234.  
  19235. It is recommended that XError use XGetErrorText for obtain-
  19236. ing textual descriptions of the specified error code.  The
  19237. definition for this function is:
  19238.  
  19239. XGetErrorText(display, code, buffer_return, length)
  19240.       Display *display;
  19241.       int code;
  19242.       char *buffer_return;
  19243.       int length;
  19244.  
  19245.  
  19246. display   Specifies the connection to the X server.
  19247.  
  19248. code      Specifies the error code for which you want to
  19249.           obtain a description.
  19250.  
  19251. buffer_returnReturns the error description.
  19252.  
  19253. length    Specifies the size of the buffer.
  19254.  
  19255. The XGetErrorText function copies a null-terminated string
  19256. describing the specified error code into the specified
  19257. buffer.  It is recommended that you use this routine to
  19258. obtain an error description because extensions to the Xlib
  19259. library may define their own error codes and error strings.
  19260.  
  19261.  
  19262. Use XGetErrorDatabaseText to obtain error messages from the
  19263. error data base.  The definition for this function is:
  19264.  
  19265. XGetErrorDatabaseText(display, name, message, default_string, buffer_return, length)
  19266.       Display display;
  19267.       char *name, *message;
  19268.       char *default_string;
  19269.       char *buffer_return;
  19270.       int length;
  19271.  
  19272.  
  19273. display   Specifies the connection to the X server.
  19274.  
  19275. name      Specifies the name of the application.
  19276.  
  19277. message   Specifies the type of the error message.
  19278.  
  19279. default_stringSpecifies the default error message.
  19280.  
  19281. buffer_returnReturns the error description.
  19282.  
  19283. length    Specifies the size of the buffer.
  19284.  
  19285. The XGetErrorDatabaseText function returns a message (or the
  19286. default masssage) from the error message database.  Given a
  19287. pair of strings as keys, XGetErrorDatabaseText uses the
  19288. resource manager to look up a string and returns in the
  19289.  
  19290.  
  19291.  
  19292.                      December 18, 1987
  19293.  
  19294.  
  19295.  
  19296.  
  19297.  
  19298.                           - 282 -
  19299.  
  19300.  
  19301. buffer argument.  Xlib uses this function internally to look
  19302. up its error messages.  On a UNIX-based system, the error
  19303. message database is /usr/lib/XerrorDB.
  19304.  
  19305. The name argument should generally be the name of your
  19306. application.  The message argument should indicate which
  19307. type of error message you want.  Three predefined sets of
  19308. names are used by Xlib to report errors:
  19309.  
  19310. o    XProtoError
  19311.  
  19312.      The protocol error number is used as a string for the
  19313.      message argument.
  19314.  
  19315. o    XlibMessage
  19316.  
  19317.      These are the message strings that are used internally
  19318.      by the library.
  19319.  
  19320. o    XRequestMajor
  19321.  
  19322.      The major request protocol number is used for the mes-
  19323.      sage argument.  If no string is found in the error data
  19324.      base, the default_string is returned to the buffer
  19325.      argument.
  19326.  
  19327.  
  19328. Use XDisplayName to report an error to the user when the
  19329. requested display does not exist.  The definition for this
  19330. function is:
  19331.  
  19332. char *XDisplayName(string)
  19333.       char *string;
  19334.  
  19335.  
  19336. string    Specifies the character string.
  19337.  
  19338. The XDisplayName function returns the name of the display
  19339. that you are currently using.  If a NULL string is speci-
  19340. fied, XDisplayName looks in the environment for the display
  19341. and returns the display name that the user was requesting.
  19342. This makes it easier to report to the user precisely which
  19343. display the program attempted to open when the initial con-
  19344. nection attempt failed.
  19345.  
  19346.  
  19347. Use XSetIOErrorHandler to handle fatal I/O errors. The
  19348. definition for this function is:
  19349.  
  19350. XSetIOErrorHandler(handler)
  19351.       int (*handler)(Display *);
  19352.  
  19353.  
  19354.  
  19355.  
  19356.  
  19357.  
  19358.                      December 18, 1987
  19359.  
  19360.  
  19361.  
  19362.  
  19363.  
  19364.                           - 283 -
  19365.  
  19366.  
  19367. handler   Specifies the program's supplied error handler.
  19368.  
  19369. The XSetIOErrorHandler sets the fatal IO error handler.  The
  19370. program's supplied error handler will be called by Xlib if
  19371. any sort of system call error occurs. For example, the con-
  19372. nection to the server was lost.  This is assumed to be a
  19373. fatal condition. That is, the called routine should not
  19374. return.  If the IO error handler does return, the client
  19375. process will exit.
  19376.  
  19377.  
  19378.  
  19379.  
  19380.  
  19381.  
  19382.  
  19383.  
  19384.  
  19385.  
  19386.  
  19387.  
  19388.  
  19389.  
  19390.  
  19391.  
  19392.  
  19393.  
  19394.  
  19395.  
  19396.  
  19397.  
  19398.  
  19399.  
  19400.  
  19401.  
  19402.  
  19403.  
  19404.  
  19405.  
  19406.  
  19407.  
  19408.  
  19409.  
  19410.  
  19411.  
  19412.  
  19413.  
  19414.  
  19415.  
  19416.  
  19417.  
  19418.  
  19419.  
  19420.  
  19421.  
  19422.  
  19423.  
  19424.                      December 18, 1987
  19425.  
  19426.  
  19427.  
  19428.  
  19429.  
  19430.                           - 284 -
  19431.  
  19432.  
  19433.  
  19434.  
  19435.                          Chapter 9
  19436.  
  19437.                Predefined Property Functions
  19438.  
  19439.  
  19440.  
  19441. Chapter 9 - Predefined Property Functions There are a number
  19442. of predefined properties for common information usually
  19443. associated with windows.  The atoms for these predefined
  19444. properties can be found in <X11/Xatom.h>.
  19445.  
  19446. Xlib provides functions with which you can perform prede-
  19447. fined property operations.  This chapter discusses how to:
  19448.  
  19449. o    Communicate with window managers
  19450.  
  19451. o    Manipulate standard colormaps
  19452.  
  19453. 9.1.  Communicating with Window Managers
  19454.  
  19455. This section discusses a set of properties and functions
  19456. that are necessary for clients to communicate effectively
  19457. with window managers.  Some of these properties have complex
  19458. structures.  Because all the data in a single property on
  19459. the server has to be of the same format (8, 16, or 32 bit),
  19460. and because the C structures representing property types
  19461. cannot be guaranteed to be uniform in the same way, Set and
  19462. Get functions are provided for properties with complex
  19463. structures to format.
  19464.  
  19465. These functions define but do not enforce minimal policy
  19466. among window managers.  Writers of window managers are urged
  19467. to use the information in these properties rather than
  19468. invent their own properties and types.  A window manager
  19469. writer, however, can define additional properties beyond
  19470. this proposed least common denominator.
  19471.  
  19472. In addition to Set and Get functions for individual proper-
  19473. ties, Xlib includes one function, XSetStandardProperties,
  19474. that sets all or portions of several properties.  The pur-
  19475. pose of XSetStandardProperties is to provide a simple inter-
  19476. face for the programmer who wants to code an application in
  19477. an afternoon.  Applications which need to communicate to the
  19478. window manager more information than is possible with
  19479. XSetStandardProperties should not use this interface.
  19480. Instead, they should call the Set functions for the addi-
  19481. tional or specific properties that they need.
  19482.  
  19483. In order to work well with most window managers, every
  19484. application should specify the following information:
  19485.  
  19486.  
  19487.  
  19488.  
  19489.  
  19490.                      December 18, 1987
  19491.  
  19492.  
  19493.  
  19494.  
  19495.  
  19496.                           - 285 -
  19497.  
  19498.  
  19499. o    Name of the application
  19500.  
  19501. o    Name string for the icon
  19502.  
  19503. o    Command used to invoke the application
  19504.  
  19505. o    Size and window manager hints as defined below
  19506.  
  19507. Xlib does not set defaults for the properties described in
  19508. this section.  Thus, the default behavior is determined by
  19509. the window manager and may be based on the presence or
  19510. absence of certain properties.  All the properties are con-
  19511. sidered to be hints to a window manager.  When implementing
  19512. window management policy, a window manager determines what
  19513. to do with this information and is allowed to ignore it.
  19514.  
  19515. The supplied properties are:
  19516.  
  19517. __________________________________________________________________
  19518. Name               Type            Format   Description
  19519. __________________________________________________________________
  19520. WM_NAME
  19521.                    STRING
  19522.                                      8
  19523.                                             Name of the applica-
  19524.                                             tion
  19525.  
  19526.  
  19527. WM_ICON_NAME
  19528.                    STRING
  19529.                                      8
  19530.                                             Name to be used in
  19531.                                             icon
  19532.  
  19533.  
  19534. WM_NORMAL_HINTS
  19535.                    WM_SIZE_HINTS
  19536.                                      32
  19537.                                             Size hints for a win-
  19538.                                             dow in its normal
  19539.                                             state.  The C type of
  19540.                                             this property is
  19541.                                             XSizeHints (see
  19542.                                             below).
  19543.  
  19544.  
  19545.  
  19546.  
  19547.  
  19548.  
  19549. WM_ZOOM_HINTS
  19550.                    WM_SIZE_HINTS
  19551.                                      32
  19552.                                             Size hints for a
  19553.                                             zoomed window.  The C
  19554.                                             type of this property
  19555.                                             is XSizeHints (see
  19556.                                             below).
  19557.  
  19558.  
  19559.  
  19560.  
  19561.  
  19562. WM_HINTS
  19563.                    WM_HINTS
  19564.                                      32
  19565.                                             Additional hints set
  19566.                                             by client for use by
  19567.                                             the window manager.
  19568.                                             The C type of this
  19569.                                             property is XWMHints
  19570.                                             (see below).
  19571.  
  19572.  
  19573.  
  19574.  
  19575.  
  19576.  
  19577. WM_COMMAND
  19578.                    STRING
  19579.                                      8
  19580.                                             The command and argu-
  19581.                                             ments, separated by
  19582.                                             ASCII 0s, used to
  19583.                                             invoke the applica-
  19584.                                             tion.
  19585.  
  19586.  
  19587.  
  19588.  
  19589.  
  19590. WM_ICON_SIZE
  19591.                    WM_ICON_SIZE
  19592.                                      32
  19593.                                             The window manager may
  19594.                                             set this property on
  19595.                                             the root window to
  19596.                                             specify the icon sizes
  19597.  
  19598.  
  19599.  
  19600.                      December 18, 1987
  19601.  
  19602.  
  19603.  
  19604.  
  19605.  
  19606.                           - 286 -
  19607.  
  19608.  
  19609. __________________________________________________________________
  19610. Name               Type            Format   Description
  19611. __________________________________________________________________
  19612.                                             it supports.  The C
  19613.                                             type of this property
  19614.                                             is XIconSize (see
  19615.                                             below).
  19616.  
  19617.  
  19618.  
  19619.  
  19620.  
  19621.  
  19622.  
  19623.  
  19624.  
  19625.  
  19626.  
  19627.  
  19628.  
  19629.  
  19630.  
  19631.  
  19632.  
  19633.  
  19634.  
  19635.  
  19636.  
  19637.  
  19638.  
  19639.  
  19640.  
  19641.  
  19642.  
  19643.  
  19644.  
  19645.  
  19646.  
  19647.  
  19648.  
  19649.  
  19650.  
  19651.  
  19652.  
  19653.  
  19654.  
  19655.  
  19656.  
  19657.  
  19658.  
  19659.  
  19660.  
  19661.  
  19662.  
  19663.  
  19664.  
  19665.  
  19666.                      December 18, 1987
  19667.  
  19668.  
  19669.  
  19670.  
  19671.  
  19672.                           - 287 -
  19673.  
  19674.  
  19675. __________________________________________________________________
  19676. Name               Type            Format   Description
  19677. __________________________________________________________________
  19678.  
  19679.  
  19680.  
  19681.  
  19682.  
  19683.  
  19684.  
  19685.  
  19686.  
  19687.  
  19688.  
  19689.  
  19690.  
  19691.  
  19692.  
  19693.  
  19694.  
  19695.  
  19696.  
  19697.  
  19698.  
  19699.  
  19700.  
  19701.  
  19702.  
  19703.  
  19704.  
  19705.  
  19706.  
  19707.  
  19708.  
  19709.  
  19710.  
  19711.  
  19712.  
  19713.  
  19714.  
  19715.  
  19716.  
  19717.  
  19718.  
  19719.  
  19720.  
  19721.  
  19722.  
  19723.  
  19724.  
  19725.  
  19726.  
  19727.  
  19728.  
  19729.  
  19730.  
  19731.  
  19732.                      December 18, 1987
  19733.  
  19734.  
  19735.  
  19736.  
  19737.  
  19738.                           - 288 -
  19739.  
  19740.  
  19741. __________________________________________________________________
  19742. Name               Type            Format   Description
  19743. __________________________________________________________________
  19744. WM_CLASS
  19745.                    STRING
  19746.                                      32
  19747.                                             Set by application
  19748.                                             programs to allow win-
  19749.                                             dow and session
  19750.                                             managers to obtain the
  19751.                                             application's
  19752.                                             resources from the
  19753.                                             resource database.
  19754.  
  19755.  
  19756.  
  19757.  
  19758.  
  19759.  
  19760.  
  19761. WM_TRANSIENT_FOR
  19762.                    WINDOW
  19763.                                      32
  19764.                                             Set by application
  19765.                                             programs to indicate
  19766.                                             to the window manager
  19767.                                             that a transient top-
  19768.                                             level window, such as
  19769.                                             a dialog box, is not
  19770.                                             really a full-fledged
  19771.                                             window.
  19772.  
  19773.  
  19774.  
  19775.  
  19776.  
  19777.  
  19778.  
  19779.  
  19780.  
  19781. __________________________________________________________________
  19782.  
  19783.  
  19784. The atom names stored in <X11/Xatom.h> are named
  19785. ``XA_PROPERTY_NAME''.
  19786.  
  19787. Xlib provides functions with which you can set and get
  19788. predefined properties. Note that calling the Set function
  19789. for a property with complex structure redefines all fields
  19790. in that property, even though only some of those fields may
  19791. have a specified new value.  Simple properties for which
  19792. Xlib does not provide a Set or Get function may be set using
  19793. XChangeProperty and their values may be retrieved using
  19794. XGetWindowProperty.  The remainder of this section discusses
  19795. how to:
  19796.  
  19797. o    Set standard properties
  19798.  
  19799. o    Set and get the name of a window
  19800.  
  19801. o    Set and get the icon name of a window
  19802.  
  19803. o    Set the command atom
  19804.  
  19805. o    Set and get window manager hints
  19806.  
  19807. o    Set and get window sizing hints
  19808.  
  19809. o    Set and get icon size hints
  19810.  
  19811. o    Set and get the class of a window
  19812.  
  19813.  
  19814.  
  19815.  
  19816.  
  19817.  
  19818.                      December 18, 1987
  19819.  
  19820.  
  19821.  
  19822.  
  19823.  
  19824.                           - 289 -
  19825.  
  19826.  
  19827. o    Set and get the transient property for a window
  19828.  
  19829.  
  19830. 9.1.1.  Setting Standard Properties
  19831.  
  19832. Use XSetStandardProperties to specify a minimum set of pro-
  19833. perties describing the ``quickie'' application. This func-
  19834. tion sets all or portions of the WM_NAME, WM_ICON_NAME,
  19835. WM_HINTS, WM_COMMAND, WM_NORMAL_HINTS properties.  The
  19836. definition for this function is:
  19837.  
  19838. XSetStandardProperties(display, w, window_name, icon_name, icon_pixmap, argv, argc, hints)
  19839.       Display *display;
  19840.       Window w;
  19841.       char *window_name;
  19842.       char *icon_name;
  19843.       Pixmap icon_pixmap;
  19844.       char **argv;
  19845.       int argc;
  19846.       XSizeHints *hints;
  19847.  
  19848.  
  19849. display   Specifies the connection to the X server.
  19850.  
  19851. w         Specifies the window ID.
  19852.  
  19853. window_nameSpecifies the name of the window.
  19854.  
  19855. icon_name Specifies the name to be displayed in the window's
  19856.           icon.
  19857.  
  19858. icon_pixmapSpecifies the pixmap that is to be used for the
  19859.           icon or None.
  19860.  
  19861. argv      Specifies a pointer to the command and arguments
  19862.           used to start the application.
  19863.  
  19864. argc      Specifies the number of arguments.
  19865.  
  19866. hints     Specifies a pointer to the sizing hints for the
  19867.           window in its normal state.
  19868.  
  19869. The XSetStandardProperties function provides a means by
  19870. which, with a single call, simple applications set the most
  19871. essential properties.  XSetStandardProperties should be used
  19872. to give a window manager some information about your
  19873. program's preferences. It should not be used by applications
  19874. which need to communicate more information than is possible
  19875. with XSetStandardProperties.  See Section 9.1.6 for a dis-
  19876. cussion of the XSizeHints structure.
  19877.  
  19878. The errors that can be generated by XSetStandardProperties
  19879. are BadWindow and BadAlloc.
  19880.  
  19881.  
  19882.  
  19883.  
  19884.                      December 18, 1987
  19885.  
  19886.  
  19887.  
  19888.  
  19889.  
  19890.                           - 290 -
  19891.  
  19892.  
  19893. 9.1.2.  Setting and Getting Window Names
  19894.  
  19895. Xlib provides functions to set and read the name of a win-
  19896. dow.  These functions set and read the WM_NAME property.
  19897.  
  19898.  
  19899. Use XStoreName to assign a name to a window. The definition
  19900. for this function is:
  19901.  
  19902. XStoreName(display, w, window_name)
  19903.       Display *display;
  19904.       Window w;
  19905.       char *window_name;
  19906.  
  19907.  
  19908. display   Specifies the connection to the X server.
  19909.  
  19910. w         Specifies the window ID.  This is the window to
  19911.           which you want to assign a name.
  19912.  
  19913. window_nameSpecifies the name of the window.  The name
  19914.           should be a null-terminated string.  This name
  19915.           will be returned by any subsequent call to XFetch-
  19916.           Name.
  19917.  
  19918. The XStoreName function assigns the name passed to
  19919. window_name to the specified window.  A window manager may
  19920. display the window name in some prominent place, such as the
  19921. title bar, to allow users to identify windows easily.  Some
  19922. window managers may display a window's name in the window's
  19923. icon, although they are encouraged to use the window's icon
  19924. name, if one is provided by the application.
  19925.  
  19926. The errors that can be generated by XStoreName are BadWindow
  19927. and BadAlloc.
  19928.  
  19929.  
  19930. Use XFetchName to get the name of a window.  The definition
  19931. for this function is:
  19932.  
  19933. int XFetchName(display, w, window_name_return)
  19934.       Display *display;
  19935.       Window w;
  19936.       char **window_name_return;
  19937.  
  19938.  
  19939. display   Specifies the connection to the X server.
  19940.  
  19941. w         Specifies the window ID.  This is the window whose
  19942.           name you want a pointer set to.
  19943.  
  19944. window_name_returnReturns a pointer to the window name,
  19945.           which will be a null-terminated string.
  19946.  
  19947.  
  19948.  
  19949.  
  19950.                      December 18, 1987
  19951.  
  19952.  
  19953.  
  19954.  
  19955.  
  19956.                           - 291 -
  19957.  
  19958.  
  19959. The XFetchName function obtains a window name and returns
  19960. either a nonzero if it succeeds or zero (0) if it fails (for
  19961. example, if no name has been set for the argument window).
  19962. If the WM_NAME property has not been set for this window,
  19963. XFetchName sets this argument to NULL.  When finished with
  19964. it, a client must free the name string  using the free
  19965. library subroutine.
  19966.  
  19967. The error that can be generated by XFetchName is BadWindow.
  19968.  
  19969. 9.1.3.  Setting and Getting Icon Names
  19970.  
  19971. Xlib provides functions to set and read the name to be
  19972. displayed in a window's icon. These functions set and read
  19973. the WM_ICON_NAME property.
  19974.  
  19975.  
  19976. Use XSetIconName to set the name to be displayed in a
  19977. window's icon.  The definition for this function is:
  19978.  
  19979. XSetIconName(display, w, icon_name)
  19980.       Display *display;
  19981.       Window w;
  19982.       char *icon_name;
  19983.  
  19984.  
  19985. display   Specifies the connection to the X server.
  19986.  
  19987. w         Specifies the window ID.  This is the window whose
  19988.           icon name is being set.
  19989.  
  19990. icon_name Specifies the name to be displayed in the window's
  19991.           icon.  The name should be a null-terminated
  19992.           string.  This name is returned by any subsequent
  19993.           call to XGetIconName.
  19994.  
  19995. The errors that can be generated by XSetIconName are BadWin-
  19996. dow and BadAlloc.
  19997.  
  19998.  
  19999. Use XGetIconName to get the name a window wants displayed in
  20000. its icon.  The definition for this function is:
  20001.  
  20002. int XGetIconName(display, w, icon_name_return)
  20003.       Display *display;
  20004.       Window w;
  20005.       char **icon_name_return;
  20006.  
  20007.  
  20008. display   Specifies the connection to the X server.
  20009.  
  20010. w         Specifies the window ID.  This is the window whose
  20011.           icon name you want a pointer set to.
  20012.  
  20013.  
  20014.  
  20015.  
  20016.                      December 18, 1987
  20017.  
  20018.  
  20019.  
  20020.  
  20021.  
  20022.                           - 292 -
  20023.  
  20024.  
  20025. icon_name_returnReturns a pointer to the name to be
  20026.           displayed in the window's icon. The name will be a
  20027.           null-terminated string.
  20028.  
  20029. The XGetIconName function obtains the window name to be
  20030. displayed in its icon and either returns a nonzero if it
  20031. succeeds or zero (0) if it fails (for example, if no icon
  20032. name has been set for the argument window).  If you never
  20033. assigned a name to the window, XGetIconName sets this argu-
  20034. ment to NULL.  When finished with it, a client must free the
  20035. icon name string using the free library subroutine.
  20036.  
  20037. The error that can be generated by XGetIconName is BadWin-
  20038. dow.
  20039.  
  20040. 9.1.4.  Setting the Command Atom
  20041.  
  20042. Use XSetCommand to set the value of the command atom.  This
  20043. function sets the WM_COMMAND property.  The definition for
  20044. this function is:
  20045.  
  20046. XSetCommand(display, w, argv, argc)
  20047.       Display *display;
  20048.       Window w;
  20049.       char **argv;
  20050.       int argc;
  20051.  
  20052.  
  20053. display   Specifies the connection to the X server.
  20054.  
  20055. w         Specifies the window ID.
  20056.  
  20057. argv      Specifies a pointer to the command and arguments
  20058.           used to start the application.
  20059.  
  20060. argc      Specifies the number of arguments.
  20061.  
  20062. The XSetCommand function records the command and arguments
  20063. used to invoke the application.
  20064.  
  20065. The errors that can be generated by XSetCommand are BadWin-
  20066. dow and BadAlloc.
  20067.  
  20068. 9.1.5.  Setting and Getting Window Manager Hints
  20069.  
  20070. The functions discussed in this section set and read the
  20071. WM_HINTS property and use the XWMHints structure:
  20072.  
  20073.  
  20074.  
  20075.  
  20076.  
  20077.  
  20078.  
  20079.  
  20080.  
  20081.  
  20082.                      December 18, 1987
  20083.  
  20084.  
  20085.  
  20086.  
  20087.  
  20088.                           - 293 -
  20089.  
  20090.  
  20091. typedef struct {
  20092.      long flags;         /* marks which fields in this structure are defined */
  20093.      Bool input;         /* does this application rely on the window manager to
  20094.                          get keyboard input? */
  20095.      int initial_state;  /* see below */
  20096.      Pixmap icon_pixmap; /* pixmap to be used as icon */
  20097.      Window icon_window; /* window to be used as icon */
  20098.      int icon_x, icon_y; /* initial position of icon */
  20099.      Pixmap icon_mask;   /* pixmap to be used as mask for icon_pixmap */
  20100.      XID window_group;   /* id of related window group */
  20101.      /* this structure may be extended in the future */
  20102. } XWMHints;
  20103.  
  20104. The definitions for the flags field are:
  20105.  
  20106. #define InputHint        (1L << 0)
  20107. #define StateHint        (1L << 1)
  20108. #define IconPixmapHint   (1L << 2)
  20109. #define IconWindowHint   (1L << 3)
  20110. #define IconPositionHint (1L << 4)
  20111. #define IconMaskHint     (1L << 5)
  20112. #define WindowGroupHint  (1L << 6)
  20113. #define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
  20114.      IconPositionHint|IconMaskHint|WindowGroupHint)
  20115.  
  20116. The input field is used to communicate to the window manager
  20117. the input focus model used by the application.  Applications
  20118. which expect input but never explicitly set focus to any of
  20119. their subwindows (use the push model of focus management),
  20120. such as X10-style applications that use real-estate driven
  20121. focus, should set this field to True.  Similarly, applica-
  20122. tions that set input focus to their subwindows only when it
  20123. is given to their top-level window by a window manager
  20124. should also set this field to True.  Applications which
  20125. manage their own input focus by explicitly setting focus to
  20126. one of their subwindows whenever they want keyboard input
  20127. (that is, use the pull model of focus management) should set
  20128. this field to False.  Applications which never expect any
  20129. keyboard input should also set this field to False.
  20130.  
  20131. Pull model window managers should make it possible for push
  20132. model applications to get input by setting input focus to
  20133. the top level windows of applications whose input field is
  20134. True.  Push model window managers should make sure that pull
  20135. model applications do not break them, by resetting input
  20136. focus to PointerRoot when appropriate (for example, whenever
  20137. an application whose input field is False sets input focus
  20138. to one of its subwindows).
  20139.  
  20140. The definitions for the initial_state flag are:
  20141.  
  20142.  
  20143.  
  20144.  
  20145.  
  20146.  
  20147.  
  20148.                      December 18, 1987
  20149.  
  20150.  
  20151.  
  20152.  
  20153.  
  20154.                           - 294 -
  20155.  
  20156.  
  20157. #define DontCareState    0     /* don't know or care */
  20158. #define NormalState      1     /* most applications want to start this way */
  20159. #define ZoomState        2     /* application wants to start zoomed */
  20160. #define IconicState      3     /* application wants to start as an icon */
  20161. #define InactiveState    4     /* application believes it is seldom used;
  20162.                               some wm's may put it on inactive menu */
  20163.  
  20164. The icon_mask specifies which pixels of the icon_pixmap
  20165. should be used as the icon. This allows for nonrectangular
  20166. pixmaps.  The window_group lets you specify that this window
  20167. belongs to a group of other windows.  For example, if a sin-
  20168. gle application manipulates multiple children of the root
  20169. window, this allows you to provide enough information that a
  20170. window manager can iconify all of the windows, rather than
  20171. just the one window.
  20172.  
  20173.  
  20174. Use XSetWMHints to set the value of the window manager hints
  20175. atom.  The definition for this function is:
  20176.  
  20177. XSetWMHints(display, w, wmhints)
  20178.       Display *display;
  20179.       Window w;
  20180.       XWMHints *wmhints;
  20181.  
  20182.  
  20183.  
  20184. display   Specifies the connection to the X server.
  20185.  
  20186. w         Specifies the window ID.
  20187.  
  20188. wmhints   Specifies a pointer to the window manager hints.
  20189.  
  20190. The XSetWMHints function sets the window manager hints that
  20191. include icon information and location, the initial state of
  20192. the window, and whether the application relies on the window
  20193. manager to get keyboard input.
  20194.  
  20195. The errors that can be generated by XSetWMHints are BadWin-
  20196. dow and BadAlloc.
  20197.  
  20198.  
  20199. Use XGetWMHints to read the value of the window manager
  20200. hints atom.  The definition for this function is:
  20201.  
  20202. XWMHints *XGetWMHints(display, w)
  20203.       Display *display;
  20204.       Window w;
  20205.  
  20206.  
  20207. display   Specifies the connection to the X server.
  20208.  
  20209.  
  20210.  
  20211.  
  20212.  
  20213.  
  20214.                      December 18, 1987
  20215.  
  20216.  
  20217.  
  20218.  
  20219.  
  20220.                           - 295 -
  20221.  
  20222.  
  20223. w         Specifies the window ID.
  20224.  
  20225. The XGetWMHints function reads the value of the window
  20226. manager hints atom and returns either NULL if it fails (for
  20227. example, if no WM_HINTS property was set on window w) or a
  20228. pointer to a XWMHints structure if it succeeds.  When fin-
  20229. ished with this function, an application must free the space
  20230. used for that structure by calling XFree.  (See Section 2.4
  20231. for further information).
  20232.  
  20233. The error that can be generated by XGetWMHints is BadWindow.
  20234.  
  20235. 9.1.6.  Setting and Getting Window Sizing Hints
  20236.  
  20237. Xlib provides functions with which you can set or get window
  20238. sizing hints.
  20239.  
  20240. The functions discussed in this section use the XSizeHints
  20241. structure:
  20242.  
  20243. typedef struct {
  20244.      long flags;         /* marks which fields in this structure are defined */
  20245.      int x, y;
  20246.      int width, height;
  20247.      int min_width, min_height;
  20248.      int max_width, max_height;
  20249.      int width_inc, height_inc;
  20250.      struct {
  20251.             int x;  /* numerator */
  20252.             int y;  /* denominator */
  20253.      } min_aspect, max_aspect;
  20254. } XSizeHints;
  20255.  
  20256. The definitions for the flags field are:
  20257.  
  20258. #define USPosition       (1L << 0)     /* user specified x, y */
  20259. #define USSize           (1L << 1)     /* user specified width, height */
  20260. #define PPosition        (1L << 2)     /* program specified position */
  20261. #define PSize            (1L << 3)     /* program specified size */
  20262. #define PMinSize         (1L << 4)     /* program specified minimum size */
  20263. #define PMaxSize         (1L << 5)     /* program specified maximum size */
  20264. #define PResizeInc       (1L << 6)     /* program specified resize increments */
  20265. #define PAspect          (1L << 7)     /* program specified min and max aspect ratios */
  20266. #define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
  20267.  
  20268. The x, y, width, and height elements describe a desired
  20269. position and size for the window.  To indicate that this
  20270. information was specified by the user, set the USPosition
  20271. and USSize flags. To indicate that it was specified by the
  20272. application without any user involvement, set PPosition and
  20273. PSize.  This allows a window manager to know that the user
  20274. specifically asked where the window should be placed or how
  20275. the window should be sized and that the window manager does
  20276. not have to rely the program's opinion.
  20277.  
  20278.  
  20279.  
  20280.                      December 18, 1987
  20281.  
  20282.  
  20283.  
  20284.  
  20285.  
  20286.                           - 296 -
  20287.  
  20288.  
  20289. The min_width and min_height elements specify the minimum
  20290. size that the window can be for the application to be use-
  20291. ful.  The max_width and max_height elements specify the max-
  20292. imum size.  The width_inc and height_inc elements define an
  20293. arithmetic progression of sizes (minimum to maximum) into
  20294. which the window prefers to be resized.  The min_aspect and
  20295. max_aspect elements are expressed as ratios of x and y, and
  20296. they allow an application to specify the range of aspect
  20297. ratios it prefers.
  20298.  
  20299. The next two functions set and read the WM_NORMAL_HINTS pro-
  20300. perty.
  20301.  
  20302.  
  20303. Use XSetNormalHints to set the size hints for a window in
  20304. its normal state.  The definition for this function is:
  20305.  
  20306. void XSetNormalHints(display, w, hints)
  20307.       Display *display;
  20308.       Window w;
  20309.       XSizeHints *hints;
  20310.  
  20311.  
  20312. display   Specifies the connection to the X server.
  20313.  
  20314. w         Specifies the window ID.
  20315.  
  20316. hints     Specifies a pointer to the sizing hints for the
  20317.           window in its normal state.
  20318.  
  20319. The XSetNormalHints function sets the size hints structure
  20320. for the specified window.  Applications use XSetNormalHints
  20321. to inform the window manager of the size or position desir-
  20322. able for that window.  In addition, an application that
  20323. wants to move or resize itself should call XSetNormalHints
  20324. and specify its new desired location and size, instead of
  20325. making direct X calls to move or resize. This is because
  20326. window managers may ignore redirected configure requests,
  20327. but they pay attention to property changes.
  20328.  
  20329. To set size hints, an application not only must assign
  20330. values to the appropriate elements in the hints structure,
  20331. but it also must set the flags field of the structure to
  20332. indicate which information is present and where it came
  20333. from. A call to XSetNormalHints is meaningless, unless the
  20334. flags field is set to indicate which elements of the struc-
  20335. ture have been assigned values.
  20336.  
  20337. The errors that can be generated by XSetNormalHints are
  20338. BadWindow and BadAlloc.
  20339.  
  20340.  
  20341. Use XGetNormalHints to return the size hints for a window in
  20342. its normal state.  The definition for this function is:
  20343.  
  20344.  
  20345.  
  20346.                      December 18, 1987
  20347.  
  20348.  
  20349.  
  20350.  
  20351.  
  20352.                           - 297 -
  20353.  
  20354.  
  20355. Status XGetNormalHints(display, w, hints_return)
  20356.       Display *display;
  20357.       Window w;
  20358.       XSizeHints *hints_return;
  20359.  
  20360.  
  20361. display   Specifies the connection to the X server.
  20362.  
  20363. w         Specifies the window ID.
  20364.  
  20365. hints_returnReturns the sizing hints for the window in its
  20366.           normal state.
  20367.  
  20368. The XGetNormalHints function returns in its last argument
  20369. the size hints for a window in its normal state.  It returns
  20370. either a nonzero status if it succeeds or zero (0) if it
  20371. fails (for example, the application specified no normal size
  20372. hints for this window).
  20373.  
  20374. The error that can be generated by XGetNormalHints is
  20375. BadWindow.
  20376.  
  20377. The next two functions set and read the WM_ZOOM_HINTS pro-
  20378. perty.
  20379.  
  20380.  
  20381. Use XSetZoomHints to set the value of the zoom hints atom.
  20382. The definition for this function is:
  20383.  
  20384. XSetZoomHints(display, w, zhints)
  20385.       Display *display;
  20386.       Window w;
  20387.       XSizeHints *zhints;
  20388.  
  20389.  
  20390. display   Specifies the connection to the X server.
  20391.  
  20392. w         Specifies the window ID.
  20393.  
  20394. zhints    Specifies a pointer to the zoom hints.
  20395.  
  20396. Many window managers think of windows in three states:
  20397. iconic, normal, or zoomed.  The XSetZoomHints function pro-
  20398. vides the window manager with information for the window in
  20399. the zoomed state.
  20400.  
  20401. The errors that can be generated by XSetZoomHints are
  20402. BadWindow and BadAlloc.
  20403.  
  20404.  
  20405. Use XGetZoomHints to read the value of the zoom hints atom.
  20406. The definition for this function is:
  20407.  
  20408.  
  20409.  
  20410.  
  20411.  
  20412.                      December 18, 1987
  20413.  
  20414.  
  20415.  
  20416.  
  20417.  
  20418.                           - 298 -
  20419.  
  20420.  
  20421. Status XGetZoomHints(display, w, zhints_return)
  20422.       Display *display;
  20423.       Window w;
  20424.       XSizeHints *zhints_return;
  20425.  
  20426.  
  20427. display   Specifies the connection to the X server.
  20428.  
  20429. w         Specifies the window ID.
  20430.  
  20431. zhints_returnReturns the zoom hints.
  20432.  
  20433. The XGetZoomHints function returns in its last argument the
  20434. size hints for a window in its zoomed state.  It returns
  20435. either a nonzero status if it succeeds or zero (0) if it
  20436. fails (for example, the application specified no zoom size
  20437. hints for this window).
  20438.  
  20439. The error that can be generated by XGetZoomHints is BadWin-
  20440. dow.
  20441.  
  20442.  
  20443. Use XSetSizeHints to set the value of any property of type
  20444. WM_SIZE_HINTS.  The definition for this function is:
  20445.  
  20446. XSetSizeHints(display, w, hints, property)
  20447.       Display *display;
  20448.       Window w;
  20449.       XSizeHints *hints;
  20450.       Atom property;
  20451.  
  20452.  
  20453. display   Specifies the connection to the X server.
  20454.  
  20455. w         Specifies the window ID.
  20456.  
  20457. hints     Specifies a pointer to the size hints.
  20458.  
  20459. property  Specifies the property atom.
  20460.  
  20461. The XSetSizeHints function sets the XSizeHints structure for
  20462. the named property and the specified window.  This is used
  20463. by XSetNormalHints and XSetZoomHints, and can be used to set
  20464. the value of any property of type WM_SIZE_HINTS. Thus, it
  20465. may be useful if other properties of that type get defined.
  20466.  
  20467. The errors that can be generated by XSetSizeHints are
  20468. BadWindow, BadAlloc and BadAtom.
  20469.  
  20470.  
  20471. Use XGetSizeHints to read the value of any property of type
  20472. WM_SIZE_HINTS.  The definition for this function is:
  20473.  
  20474.  
  20475.  
  20476.  
  20477.  
  20478.                      December 18, 1987
  20479.  
  20480.  
  20481.  
  20482.  
  20483.  
  20484.                           - 299 -
  20485.  
  20486.  
  20487. Status XGetSizeHints(display, w, hints_return, property)
  20488.       Display *display;
  20489.       Window w;
  20490.       XSizeHints *hints_return;
  20491.       Atom property;
  20492.  
  20493.  
  20494. display   Specifies the connection to the X server.
  20495.  
  20496. w         Specifies the window ID.
  20497.  
  20498. hints_returnReturns the size hints.
  20499.  
  20500. property  Specifies the property atom.
  20501.  
  20502. XGetSizeHints returns the XSizeHints structure for the named
  20503. property and the specified window.  This is used by XGetNor-
  20504. malHints and XGetZoomHints.  It also can be used to retrieve
  20505. the value of any property of type SIZE_HINTS. Thus, it may
  20506. be useful if other properties of that type get defined.
  20507. XGetSizeHints returns a nonzero status if a size hint was
  20508. defined and zero (0) otherwise.
  20509.  
  20510. The errors that can be generated by XGetSizeHints are
  20511. BadWindow and BadAtom.
  20512.  
  20513. 9.1.7.  Setting and Getting Icon Sizing Hints
  20514.  
  20515. Applications can cooperate with window managers by providing
  20516. icons in sizes supported by a window manager.  To communi-
  20517. cate the supported icon sizes to the applications, a window
  20518. manager should set the icon size property on the root win-
  20519. dow. To find out what icon sizes a window manager supports,
  20520. applications should read the icon size property from the
  20521. root window.
  20522.  
  20523. The functions discussed in this section set or read the
  20524. WM_ICON_SIZE property.  In addition, they use the XIconSize
  20525. structure:
  20526.  
  20527. typedef struct {
  20528.      int min_width, min_height;
  20529.      int max_width, max_height;
  20530.      int width_inc, height_inc;
  20531. } XIconSize;
  20532.  
  20533. The width_inc and height_inc elements define an arithmetic
  20534. progression of sizes (minimum to maximum) that represent the
  20535. supported icon sizes.
  20536.  
  20537.  
  20538. Use XSetIconSizes to set the value of the icon size atom.
  20539. The definition for this function is:
  20540.  
  20541.  
  20542.  
  20543.  
  20544.                      December 18, 1987
  20545.  
  20546.  
  20547.  
  20548.  
  20549.  
  20550.                           - 300 -
  20551.  
  20552.  
  20553. XSetIconSizes(display, w, size_list, count)
  20554.       Display *display;
  20555.       Window w;
  20556.       XIconSize *size_list;
  20557.       int count;
  20558.  
  20559.  
  20560. display   Specifies the connection to the X server.
  20561.  
  20562. w         Specifies the window ID.
  20563.  
  20564. size_list Specifies a pointer to the size list.
  20565.  
  20566. count     Specifies the number of items in the size list.
  20567.  
  20568. The XSetIconSizes function is used only by window managers
  20569. to set the supported icon sizes.
  20570.  
  20571. The errors that can be generated by XSetIconSizes are
  20572. BadWindow and BadAlloc.
  20573.  
  20574.  
  20575. Use XGetIconSizes to return the value of the icon sizes
  20576. atom.  The definition for this function is:
  20577.  
  20578. Status XGetIconSizes(display, w, size_list_return, count_return)
  20579.       Display *display;
  20580.       Window w;
  20581.       XIconSize **size_list_return;
  20582.       int *count_return;
  20583.  
  20584.  
  20585. display   Specifies the connection to the X server.
  20586.  
  20587. w         Specifies the window ID.
  20588.  
  20589. size_list_returnReturns a pointer to the size list.
  20590.  
  20591. count_returnReturns the number of items in the size list.
  20592.  
  20593. The XGetIconSizes function returns zero (0) if a window
  20594. manager has not set icon sizes and nonzero status otherwise.
  20595. This function should be called by an application which wants
  20596. to find out what icon sizes would be most appreciated by the
  20597. window manager under which the application is running. The
  20598. application should then use XSetWMHints to supply the window
  20599. manager with an icon pixmap or window in one of the sup-
  20600. ported sizes.
  20601.  
  20602. The error that can be generated by XGetIconSizes is BadWin-
  20603. dow.
  20604.  
  20605.  
  20606.  
  20607.  
  20608.  
  20609.  
  20610.                      December 18, 1987
  20611.  
  20612.  
  20613.  
  20614.  
  20615.  
  20616.                           - 301 -
  20617.  
  20618.  
  20619. 9.1.8.  Setting and Getting the Class of a Window
  20620.  
  20621. Xlib provides functions to set and get the class of a win-
  20622. dow.  These functions set and read the WM_CLASS property.
  20623. In addition, they use the XWMClass structure:
  20624.  
  20625. typedef struct{
  20626.      char *res_name;
  20627.      char *res_class;
  20628. } XWMClassHint;
  20629.  
  20630.  
  20631. The res_name member contains the application name, while the
  20632. res_class member contains the application class. Note that
  20633. the name set in this property may differ from the name set
  20634. as WM_NAME.  That is, WM_NAME specifies what should be
  20635. displayed in the title bar and, therefore, may contain tem-
  20636. poral information (for example, the name of a file currently
  20637. in an editor's buffer).  n the other hand, the name speci-
  20638. fied as part of WM_CLASS is the formal name of the applica-
  20639. tion that should be used when retrieving the application's
  20640. resources from the resource database.
  20641.  
  20642.  
  20643. Use XSetClassHint to set the class of a window.  The defini-
  20644. tion of this function is:
  20645.  
  20646. XSetClassHint(display, w, class_hints)
  20647.       Display *display;
  20648.       Window w;
  20649.       XClassHint *class_hints;
  20650.  
  20651.  
  20652. display   Specifies the connection to the X server.
  20653.  
  20654. w         Specifies the window ID.
  20655.  
  20656. class_hintsSpecifies a pointer to a XWMClassHint structure
  20657.           that is to be used.
  20658.  
  20659. The XSetClassHint functions sets the class hint for the
  20660. specified window.
  20661.  
  20662. The errors that can be generated by XSetClassHint are
  20663. BadWindow and BadAlloc.
  20664.  
  20665.  
  20666. Use XGetClassHint to  get the class of a window.  The defin-
  20667. ition of this function is:
  20668.  
  20669. Status XGetClassHint(display, w, class_hints_return)
  20670.       Display *display;
  20671.       Window w;
  20672.       XClassHint *class_hints_return;
  20673.  
  20674.  
  20675.  
  20676.                      December 18, 1987
  20677.  
  20678.  
  20679.  
  20680.  
  20681.  
  20682.                           - 302 -
  20683.  
  20684.  
  20685. display   Specifies the connection to the X server.
  20686.  
  20687. w         Specifies the window ID.
  20688.  
  20689. class_hints_returnReturns the XWMClassHints structure.
  20690.  
  20691. The XGetClassHint function obtains the class of the speci-
  20692. fied window.
  20693.  
  20694. The error that can be generated by XGetClassHint is BadWin-
  20695. dow.
  20696.  
  20697. 9.1.9.  Setting and Getting the Transient Property
  20698.  
  20699. An application may want to indicate to the window manager
  20700. that a transient top-level window (for example, a dialog
  20701. box) is not really a full-fledged window.  Rather, it is
  20702. operating on behalf of (or is transient for) another window.
  20703. To do so, the application would set the WM_TRANSIENT_FOR
  20704. property of the dialog box to be the window handle of its
  20705. main window.  Some window managers may use this information
  20706. to unmap an application's dialog boxes (for example, when
  20707. the main application window gets iconified).
  20708.  
  20709. The functions discussed in this section set and read the
  20710. WM_TRANSIENT_FOR property.
  20711.  
  20712.  
  20713. Use XSetTransientForHint to set the WM_TRANSIENT_FOR pro-
  20714. perty for a window.  The definition of this function is:
  20715.  
  20716. XSetTransientForHint(display, w, prop_window)
  20717.       Display *display;
  20718.       Window w;
  20719.       Window prop_window;
  20720.  
  20721.  
  20722. display   Specifies the connection to the X server.
  20723.  
  20724. w         Specifies the window ID.
  20725.  
  20726. prop_windowSpecifies the window ID that the WM_TRANSIENT_FOR
  20727.           property is to be set to.
  20728.  
  20729. The XSetTransientForHint set the WM_TRANSIENT_FOR atom of
  20730. the specified window to the specified prop_window.
  20731.  
  20732. The errors that can be generated by XSetTransientForHint are
  20733. BadWindow and BadAlloc.
  20734.  
  20735.  
  20736. Use XGetTransientForHint to get the WM_TRANSIENT_FOR value
  20737. for a window.  The definition of this function is:
  20738.  
  20739.  
  20740.  
  20741.  
  20742.                      December 18, 1987
  20743.  
  20744.  
  20745.  
  20746.  
  20747.  
  20748.                           - 303 -
  20749.  
  20750.  
  20751. Status XGetTransientForHint(display, w, prop_window_return)
  20752.       Display *display;
  20753.       Window w;
  20754.       Window *prop_window_return;
  20755.  
  20756.  
  20757. display   Specifies the connection to the X server.
  20758.  
  20759. w         Specifies the window ID.
  20760.  
  20761. prop_window_returnReturns the WM_TRANSIENT_FOR property of
  20762.           the specified window.
  20763.  
  20764. The XGetTransientForHint function obtains the
  20765. WM_TRANSIENT_FOR property for the specified window.
  20766.  
  20767. The error that can be generated by XGetTransientForHint is
  20768. BadWindow.
  20769.  
  20770. 9.2.  Manipulating Standard Colormaps
  20771.  
  20772. Applications with color palettes, smooth-shaded drawings, or
  20773. digitized images demand large numbers of colors. In addi-
  20774. tion, these application often require an efficient mapping
  20775. from color triples to pixel values that display the
  20776. appropriate colors.
  20777.  
  20778. As an example, consider a 3D display program that wants to
  20779. draw a smoothly shaded sphere. At each pixel in the image of
  20780. the sphere, the program computes the intensity and color of
  20781. light reflected back to the viewer. The result of each com-
  20782. putation is a triple of red, green, and blue coefficients in
  20783. the range 0.0 to 1.0. To draw the sphere, the program needs
  20784. a colormap that provides a large range of uniformly distri-
  20785. buted colors. The colormap should be arranged so that the
  20786. program can convert its RGB triples into pixel values very
  20787. quickly, because drawing the entire sphere will require many
  20788. such conversions.
  20789.  
  20790. On many current workstations the display is limited to 256
  20791. or fewer colors. Applications must allocate colors carefully
  20792. not only to make sure they cover the entire range they need
  20793. but also to make use of as many of the available colors as
  20794. possible.  On a typical X display, many applications are
  20795. active at once.  Most workstations have only one hardware
  20796. lookup table for colors, so only one application colormap
  20797. can be installed at a given time.  The application using the
  20798. installed colormap is displayed correctly, while the other
  20799. applications ``go technicolor'' and are displayed with false
  20800. colors.
  20801.  
  20802. As another example, consider a user who is running an image
  20803. processing program to display earth-resources data. The
  20804. image processing program needs a colormap set up with 8
  20805.  
  20806.  
  20807.  
  20808.                      December 18, 1987
  20809.  
  20810.  
  20811.  
  20812.  
  20813.  
  20814.                           - 304 -
  20815.  
  20816.  
  20817. reds, 8 greens, and 4 blues (total of 256 colors).  Because
  20818. some colors are already in use in the default colormap, the
  20819. image processing program allocates and installs a new color-
  20820. map.
  20821.  
  20822. The user decides to alter some of the colors in the image.
  20823. He invokes a color palette program to mix and choose colors.
  20824. The color palette program also needs a colormap with 8 reds,
  20825. 8 greens, and 4 blues, so, just as the image-processing pro-
  20826. gram, it must allocate and install a new colormap.
  20827.  
  20828. Because only one colormap can be installed at a time, the
  20829. color palette may be displayed incorrectly whenever the
  20830. image-processing program is active.  Conversely, whenever
  20831. the palette program is active, the image may be displayed
  20832. incorrectly. The user can never match or compare colors in
  20833. the palette and image.  Contention for colormap resources
  20834. can be reduced if applications with similar color needs
  20835. share colormaps.
  20836.  
  20837. As another example, the image processing program and the
  20838. color palette program could share the same colormap if there
  20839. existed a convention that described how the colormap was set
  20840. up. Whenever either program was active, both would be
  20841. displayed correctly.
  20842.  
  20843. The standard colormap properties define a set of commonly
  20844. used colormaps. Applications that share these colormaps and
  20845. conventions display true colors more often and provide a
  20846. better interface to the user.
  20847.  
  20848. 9.2.1.  Standard Colormaps
  20849.  
  20850. Standard colormaps allow applications to share commonly used
  20851. color resources. This allows many applications to be
  20852. displayed in true colors simultaneously, even when each
  20853. application needs an entirely filled colormap.
  20854.  
  20855. Several standard colormaps are described. Usually, these
  20856. colormaps are created by a window manager. Applications
  20857. should use the standard colormaps if they already exist.  If
  20858. the standard colormaps do not exist, applications should
  20859. create new standard colormaps.
  20860.  
  20861. The XStandardColormap structure contains:
  20862.  
  20863.  
  20864.  
  20865.  
  20866.  
  20867.  
  20868.  
  20869.  
  20870.  
  20871.  
  20872.  
  20873.  
  20874.                      December 18, 1987
  20875.  
  20876.  
  20877.  
  20878.  
  20879.  
  20880.                           - 305 -
  20881.  
  20882.  
  20883. typedef struct {
  20884.      Colormap colormap;
  20885.      unsigned long red_max;
  20886.      unsigned long red_mult;
  20887.      unsigned long green_max;
  20888.      unsigned long green_mult;
  20889.      unsigned long blue_max;
  20890.      unsigned long blue_mult;
  20891.      unsigned long base_pixel;
  20892. } XStandardColormap;
  20893.  
  20894. The colormap field is the ID of a colormap created by the
  20895. XCreateColormap function.  The red_max, green_max, and
  20896. blue_max fields give the maximum red, green, and blue
  20897. values, respectively. Each color coefficient ranges from
  20898. zero (0) to its max, inclusive. For example, a common color-
  20899. map allocation is 3/3/2 (3 planes for red, 3 planes for
  20900. green, and 2 planes for blue). This colormap would have
  20901. red_max = 7, green_max = 7, and blue_max = 3. An alternate
  20902. allocation that uses only 216 colors is red_max = 5,
  20903. green_max = 5, and blue_max = 5.
  20904.  
  20905. The red_mult, green_mult, and blue_mult fields give the
  20906. scale factors used to compose a full pixel value. (See the
  20907. discussion of the base_pixel field for further information.)
  20908. For a 3/3/2 allocation red_mult might be 32, green_mult
  20909. might be 4, and blue_mult might be 1. For a 6-colors-each
  20910. allocation, red_mult might be 36, green_mult might be 6, and
  20911. blue_mult might be 1.
  20912.  
  20913. The base_pixel field gives the base pixel value used to com-
  20914. pose a full pixel value. Usually, the base_pixel is obtained
  20915. from a call to the XAllocColorPlanes function. Given integer
  20916. red, green, and blue coefficients in their appropriate
  20917. ranges, one then can compute a corresponding pixel value by
  20918. using the following expression.
  20919.  
  20920.  
  20921.         r * red_mult + g * green_mult + b * blue_mult + base_pixel
  20922.  
  20923. For gray-scale colormaps, only the colormap, red_max,
  20924. red_mult, and base_pixel fields are defined. The other
  20925. fields are ignored.
  20926.  
  20927. To compute a gray-scale pixel value, use the following
  20928. expression.
  20929.  
  20930.  
  20931.         gray * red_mult + base_pixel
  20932.  
  20933. The properties containing the XStandardColormap information
  20934. have the type RGB_COLOR_MAP.
  20935.  
  20936.  
  20937.  
  20938.  
  20939.  
  20940.                      December 18, 1987
  20941.  
  20942.  
  20943.  
  20944.  
  20945.  
  20946.                           - 306 -
  20947.  
  20948.  
  20949. 9.2.2.  Standard Colormap Properties and Atoms
  20950.  
  20951. Several standard colormaps are available. Each standard
  20952. colormap is defined by a property, and each such property is
  20953. identified by an atom. The following list names the atoms
  20954. and describes the colormap associated with each one.
  20955.  
  20956. RGB_DEFAULT_MAPThis atom names a property.  The value of the
  20957.           property is an XStandardColormap.
  20958.  
  20959.           The property defines an RGB subset of the system
  20960.           default colormap. Some applications only need a
  20961.           few RGB colors and may be able to allocate them
  20962.           from the system default colormap.  This is the
  20963.           ideal situation, since the fewer colormaps are
  20964.           active in the system the more applications are
  20965.           displayed with correct colors at all times.
  20966.  
  20967.           A typical allocation for the RGB_DEFAULT_MAP on
  20968.           8-plane displays is 6 reds, 6 greens, and 6 blues.
  20969.           This gives 216 uniformly distributed colors (6
  20970.           intensities of 36 different hues) and still leaves
  20971.           40 elements of a 256-element colormap available
  20972.           for special-purpose colors for text, borders, and
  20973.           so on.
  20974.  
  20975. RGB_BEST_MAP
  20976.           This atom names a property.  The value of the pro-
  20977.           perty is an XStandardColormap.
  20978.  
  20979.           The property defines the best RGB colormap avail-
  20980.           able on the display.  (Of course, this is a sub-
  20981.           jective evaluation.)  Many image processing and 3D
  20982.           applications need to use all available colormap
  20983.           cells and distribute as many perceptually distinct
  20984.           colors as possible over those cells.  This implies
  20985.           that there may be more green values available than
  20986.           red, as well as more green or red than blue.
  20987.  
  20988.           On an 8-plane pseudocolor display, RGB_BEST_MAP is
  20989.           a 3/3/2 allocation. On a 24-plane directcolor
  20990.           display, RGB_BEST_MAP is an 8/8/8 allocation. On
  20991.           other displays, RGB_BEST_MAP is purely up to the
  20992.           implementor of the display.
  20993.  
  20994. RGB_RED_MAP
  20995. RGB_GREEN_MAP
  20996. RGB_BLUE_MAPThese atoms name properties.  The values of the
  20997.           properties are XStandardColormaps.
  20998.  
  20999.           The properties define all-red, all-green, and
  21000.           all-blue colormaps, respectively. These maps are
  21001.           used by applications that want to make color-
  21002.           separated images. For example, a user might
  21003.  
  21004.  
  21005.  
  21006.                      December 18, 1987
  21007.  
  21008.  
  21009.  
  21010.  
  21011.  
  21012.                           - 307 -
  21013.  
  21014.  
  21015.           generate a full-color image on an 8-plane display
  21016.           both by rendering an image three times (once with
  21017.           high color resolution in red, once with green, and
  21018.           once with blue) and by multiply-exposing a single
  21019.           frame in a camera.
  21020.  
  21021. RGB_GRAY_MAPThis atom names a property.  The value of the
  21022.           property is an XStandardColormap.
  21023.  
  21024. The property describes the best gray-scale colormap avail-
  21025. able on the display. As previously mentioned, only the
  21026. colormap, red_max, red_mult, and base_pixel fields of the
  21027. XStandardColormap structure are used for gray-scale color-
  21028. maps.
  21029.  
  21030. 9.2.3.  Getting and Setting the XStandardColormap Structure
  21031.  
  21032. Use XGetStandardColormap to get the XStandardColormap struc-
  21033. ture associated with one of the described atoms. The defini-
  21034. tion for this function is:
  21035.  
  21036. Status XGetStandardColormap(display, w, cmap_return, property)
  21037.       Display *display;
  21038.       Window w;
  21039.       XStandardColormap *cmap_return;
  21040.       Atom property;          /* RGB_BEST_MAP, etc. */
  21041.  
  21042.  
  21043. display   Specifies the connection to the X server.
  21044.  
  21045. w         Specifies the window ID.
  21046.  
  21047. cmap_returnReturns the colormap associated with the speci-
  21048.           fied atom.
  21049.  
  21050. property  Specifies the property atom.
  21051.  
  21052. The XGetStandardColormap function returns the colormap
  21053. definition associated with the atom supplied as the property
  21054. argument. For example, to fetch the standard gray-scale
  21055. colormap for a display, you use XGetStandardColormap with
  21056. the following syntax:
  21057.  
  21058. XGetStandardColormap(dpy, DefaultRootWindow(dpy), &cmap, RGB_GRAY_MAP);
  21059.  
  21060. Once you have fetched a standard colormap, you can use it to
  21061. convert RGB values into pixel values. For example, given an
  21062. XStandardColormap structure and floating point RGB coeffi-
  21063. cients in the range 0.0 to 1.0, you can compose pixel values
  21064. with the following C expression:
  21065.  
  21066.  
  21067.  
  21068.  
  21069.  
  21070.  
  21071.  
  21072.                      December 18, 1987
  21073.  
  21074.  
  21075.  
  21076.  
  21077.  
  21078.                           - 308 -
  21079.  
  21080.  
  21081. pixel = base_pixel
  21082.      + ((unsigned long) (0.5 + r * red_max)) * red_mult
  21083.      + ((unsigned long) (0.5 + g * green_max)) * green_mult
  21084.      + ((unsigned long) (0.5 + b * blue_max)) * blue_mult;
  21085.  
  21086. The use of addition rather than logical OR for composing
  21087. pixel values permits allocations where the RGB value is not
  21088. aligned to bit boundaries.
  21089.  
  21090. The errors that can be generated by XGetStandardColormap are
  21091. BadWindow and BadAtom.
  21092.  
  21093.  
  21094. Use XSetStandardColormap to create or change a standard
  21095. colormap. The definition for this function is:
  21096.  
  21097. void XSetStandardColormap(display, w, cmap, property)
  21098.       Display *display;
  21099.       Window w;
  21100.       XStandardColormap *cmap;
  21101.       Atom property;          /* RGB_BEST_MAP, etc. */
  21102.  
  21103.  
  21104. display   Specifies the connection to the X server.
  21105.  
  21106. w         Specifies the window ID.
  21107.  
  21108. cmap      Specifies the color map ID.
  21109.  
  21110. property  Specifies the property atom.
  21111.  
  21112. The XSetStandardColormap function usually is only used by
  21113. window managers. To create a standard colormap, follow this
  21114. procedure:
  21115.  
  21116. 1.   Grab the server.
  21117.  
  21118. 2.   See if the property is on the property list of the root
  21119.      window for the display.
  21120.  
  21121. 3.   If the desired property is not present, do the follow-
  21122.      ing:
  21123.  
  21124.      o    Create a colormap (not required for
  21125.           RGB_DEFAULT_MAP)
  21126.  
  21127.      o    Determine the color capabilities of the display.
  21128.  
  21129.      o    Call XAllocColorPlanes or XAllocColorCells to
  21130.           allocate cells in the colormap.
  21131.  
  21132.      o    Call XStoreColors to store appropriate color
  21133.           values in the colormap.
  21134.  
  21135.  
  21136.  
  21137.  
  21138.                      December 18, 1987
  21139.  
  21140.  
  21141.  
  21142.  
  21143.  
  21144.                           - 309 -
  21145.  
  21146.  
  21147.      o    Fill in the descriptive fields in the property.
  21148.  
  21149.      o    Attach the property to the root window.
  21150.  
  21151. 4.   Ungrab the server.
  21152.  
  21153. The errors that can be generated by XSetStandardColormap are
  21154. BadWindow, BadAtom, and BadAlloc.
  21155.  
  21156.  
  21157.  
  21158.  
  21159.  
  21160.  
  21161.  
  21162.  
  21163.  
  21164.  
  21165.  
  21166.  
  21167.  
  21168.  
  21169.  
  21170.  
  21171.  
  21172.  
  21173.  
  21174.  
  21175.  
  21176.  
  21177.  
  21178.  
  21179.  
  21180.  
  21181.  
  21182.  
  21183.  
  21184.  
  21185.  
  21186.  
  21187.  
  21188.  
  21189.  
  21190.  
  21191.  
  21192.  
  21193.  
  21194.  
  21195.  
  21196.  
  21197.  
  21198.  
  21199.  
  21200.  
  21201.  
  21202.  
  21203.  
  21204.                      December 18, 1987
  21205.  
  21206.  
  21207.  
  21208.  
  21209.  
  21210.                           - 310 -
  21211.  
  21212.  
  21213.  
  21214.  
  21215.                          Chapter 10
  21216.  
  21217.                Application Utility Functions
  21218.  
  21219.  
  21220.  
  21221. Chapter 10 - Application Utility Functions Once you have
  21222. initialized the X system, you can use the Xlib utility func-
  21223. tions to:
  21224.  
  21225. o    Handle keyboard events
  21226.  
  21227. o    Obtain the X environment defaults
  21228.  
  21229. o    Parse the window geometry
  21230.  
  21231. o    Parse the hardware colors
  21232.  
  21233. o    Generate regions
  21234.  
  21235. o    Manipulate regions
  21236.  
  21237. o    Use the cut and paste buffers
  21238.  
  21239. o    Determine the appropriate visual
  21240.  
  21241. o    Manipulate images
  21242.  
  21243. o    Manipulate bitmaps
  21244.  
  21245. o    Use the resource manager
  21246.  
  21247. o    Use the context manager
  21248.  
  21249.                             Note
  21250.  
  21251.      As a group, the functions discussed in this
  21252.      chapter provide the functionality that is fre-
  21253.      quently needed and spans toolkits.  These func-
  21254.      tions do not generate actual protocol requests to
  21255.      the server.
  21256.  
  21257.  
  21258. 10.1.  Keyboard Utility Functions
  21259.  
  21260. Xlib provides with which you manipulate keyboard event or
  21261. can determine information about a keysym.  This section
  21262. discusses:
  21263.  
  21264. o    Keyboard event functions
  21265.  
  21266.  
  21267.  
  21268.  
  21269.  
  21270.                      December 18, 1987
  21271.  
  21272.  
  21273.  
  21274.  
  21275.  
  21276.                           - 311 -
  21277.  
  21278.  
  21279. o    Keysym classification macros
  21280.  
  21281. 10.1.1.  Keyboard Event Functions
  21282.  
  21283. The X server does not predefine the keyboard to be ASCII
  21284. characters.  It is often useful to know that the ``a'' key
  21285. was just pressed or possibly that it was just released.
  21286. When a key is pressed or released, the X server sends key-
  21287. board events to client programs.  The structures associated
  21288. with keyboard events contain a keycode member that assigns a
  21289. number to each physical key on the keyboard.  See Section
  21290. 8.4.1 for a discussion of keyboard event processing.  See
  21291. Section 7.9 for information on how to manipulate the key-
  21292. board encoding.
  21293.  
  21294. Because keycodes are completely arbitrary and may differ
  21295. from server to server, client programs wanting to deal with
  21296. ASCII text, for example, must explicitly convert the keycode
  21297. value into ASCII.  The transformation of keycodes to ASCII
  21298. or other character sets is arbitrary.  Therefore, Xlib pro-
  21299. vides functions to help you customize the keyboard layout.
  21300. Keyboards often differ dramatically, so writing code that
  21301. presumes the existence of a particular key on the main key-
  21302. board will create portability problems.  It may also be dif-
  21303. ficult to receive KeyRelease events on certain X server
  21304. implementations because of hardware or software restric-
  21305. tions.
  21306.  
  21307. Keyboard events are usually sent to the smallest enclosing
  21308. window which is interested in that type of event underneath
  21309. the pointer's position.  It is also possible to assign the
  21310. keyboard input focus to a specific window.  When the input
  21311. focus is attached to a window, keyboard events will go to
  21312. the client which has selected input on that window rather
  21313. than the window under the pointer.
  21314.  
  21315. This section discusses the functions with which you can
  21316. query the keyboard, look up the keyboard mappings, rebind
  21317. the keyboard, or use an alternate keyboard mapping file.
  21318.  
  21319.                             Note
  21320.  
  21321.      Some implementations cannot support KeyRelease
  21322.      events.  You should think seriously before design-
  21323.      ing software that takes advantage of KeyRelease
  21324.      events if you are concerned about wide portabil-
  21325.      ity, though there are some applications that can
  21326.      exploit KeyRelease events to provide superior user
  21327.      interfaces.  You should also be very careful when
  21328.      selecting which keys may be used in such applica-
  21329.      tions.  It may be impossible to guarantee the
  21330.      existence of a set of keys on all keyboards with
  21331.      the probable exception of a-z, spacebar, and car-
  21332.      riage return.
  21333.  
  21334.  
  21335.  
  21336.                      December 18, 1987
  21337.  
  21338.  
  21339.  
  21340.  
  21341.  
  21342.                           - 312 -
  21343.  
  21344.  
  21345. Use XLookupKeysym to look up the KeySyms.  The definition
  21346. for this function is:
  21347.  
  21348. KeySym XLookupKeysym(event_key, index)
  21349.       XKeyEvent *event_key;
  21350.       int index;
  21351.  
  21352.  
  21353. event_key Specifies the key event that is to be used.  This
  21354.           event is either a KeyPress event or a KeyRelease
  21355.           event.
  21356.  
  21357. index     Specifies the index into the KeySyms table.
  21358.  
  21359. The XLookupKeysym function uses a given keyboard event and
  21360. the index you specified to return the KeySym from the list
  21361. that corresponds to the keycode member in the
  21362. XKeyPressedEvent or XKeyReleasedEvent structure.
  21363.  
  21364.  
  21365. Use XRefreshKeyboardMapping to refresh the stored modifier
  21366. and keymap information. The definition for this function is:
  21367.  
  21368. XRefreshKeyboardMapping(event_map)
  21369.       XMappingEvent *event_map;
  21370.  
  21371.  
  21372. event_map Specifies the mapping event that is to be used.
  21373.  
  21374. The XRefreshKeyboardMapping function refreshes the stored
  21375. modifier and keymap information.  You usually call this
  21376. function when a MappingNotify event occurs. The result is to
  21377. update a client application's knowledge of the keyboard.
  21378. See Section 8.4.7.7 for information on MappingNotify event
  21379. processing.
  21380.  
  21381.  
  21382. Use XLookupString to map a key event to an ASCII string. The
  21383. definition for this function is:
  21384.  
  21385. int XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_return)
  21386.       XKeyEvent *event_struct;
  21387.       char *buffer_return;
  21388.       int bytes_buffer;
  21389.       KeySym *keysym_return;
  21390.       XComposeStatus *status_return;
  21391.  
  21392.  
  21393. event_structSpecifies the key event structure to be used:
  21394.           XKeyPressedEvent or XKeyReleasedEvent.
  21395.  
  21396. buffer_returnReturns the translated characters.
  21397.  
  21398.  
  21399.  
  21400.  
  21401.  
  21402.                      December 18, 1987
  21403.  
  21404.  
  21405.  
  21406.  
  21407.  
  21408.                           - 313 -
  21409.  
  21410.  
  21411. bytes_bufferSpecifies the length of the buffer.  No more
  21412.           than bytes_buffer of translation are returned.
  21413.  
  21414. keysym_returnIf this argument is not NULL, returns the
  21415.           keysym computed from the event.
  21416.  
  21417. status_returnSpecifies either a pointer to the XCompose
  21418.           structure that is to contain compose key state
  21419.           information and that allows compose key processing
  21420.           to take place, or NULL.
  21421.  
  21422. The XLookupString function is a convenience routine that can
  21423. be used to map a key event to an ASCII string, using the
  21424. modifier bits in the key event to deal with shift, lock, and
  21425. control.  It returns the translated string into the user's
  21426. buffer. It also detects any rebound keysyms (see XRe-
  21427. bindKeysym) and returns the specified bytes.  XLookupString
  21428. returns, as its value, the length of the string stored in
  21429. the tag buffer.  If the lock modifier has a caps_lock key
  21430. associated with it, XLookupString interprets the lock modif-
  21431. ier to perform caps lock processing.
  21432.  
  21433.  
  21434. Use XRebindKeysym to rebind the meaning of a keysym for a
  21435. client.  The definition for this function is:
  21436.  
  21437. XRebindKeysym(display, keysym, list, mod_count, string, bytes_string)
  21438.       Display *display;
  21439.       KeySym keysym;
  21440.       KeySym *list;
  21441.       int mod_count;
  21442.       unsigned char *string;
  21443.       int bytes_string;
  21444.  
  21445.  
  21446. display   Specifies the connection to the X server.
  21447.  
  21448. keysym    Specifies the keysym to be rebound.
  21449.  
  21450. list      Specifies a pointer to an array of keysyms that
  21451.           are being used as modifiers.
  21452.  
  21453. mod_count Specifies the number of modifiers in the modifier
  21454.           list.
  21455.  
  21456. string    Specifies a pointer to the string that is to be
  21457.           returned by XLookupString.
  21458.  
  21459. bytes_stringSpecifies the length of the string.
  21460.  
  21461. The XRebindKeysym function can be used to rebind the meaning
  21462. of a keysym for the client.  It does not redefine the key-
  21463. code in the X server but merely provides an easy way for
  21464. long strings to be attached to keys.  XLookupString returns
  21465.  
  21466.  
  21467.  
  21468.                      December 18, 1987
  21469.  
  21470.  
  21471.  
  21472.  
  21473.  
  21474.                           - 314 -
  21475.  
  21476.  
  21477. this string when the appropriate set of modifier keys are
  21478. pressed and when the keysym would have been used for the
  21479. translation.  Note that you can rebind a keysym that may not
  21480. exist.
  21481.  
  21482.  
  21483. Use XStringToKeysym to convert the name of the keysym to the
  21484. keysym code.  The definition for this function is:
  21485.  
  21486. KeySym XStringToKeysym(string)
  21487.       char *string;
  21488.  
  21489.  
  21490. string    Specifies the name of the keysym that is to be
  21491.           converted.
  21492.  
  21493. Valid keysym names are listed in <X11/keysymdef.h>.  If the
  21494. specified string does not match a valid keysym,
  21495. XStringToKeysym returns NoSymbol.
  21496.  
  21497.  
  21498. Use XKeysymToString to convert a keysym code to the name of
  21499. the keysym.  The definition for this function is:
  21500.  
  21501. char *XKeysymToString(keysym_str)
  21502.       KeySym keysym_str;
  21503.  
  21504.  
  21505. keysym_strSpecifies the keysym that is to be converted.
  21506.  
  21507. The returned string is in a static area and must not be
  21508. modified.  If the specified keysym is not defined, XKeysym-
  21509. ToString returns a NULL.
  21510.  
  21511.  
  21512. Use XKeycodeToKeysym to convert a key code to a defined
  21513. keysym.  The definition for this function is:
  21514.  
  21515. KeySym XKeycodeToKeysym(display, keycode, index_return)
  21516.       Display *display;
  21517.       KeyCode keycode;
  21518.       int index_return;
  21519.  
  21520.  
  21521. display   Specifies the connection to the X server.
  21522.  
  21523. keycode   Specifies the keycode.
  21524.  
  21525. index_returnReturns the element of keycode vector.
  21526.  
  21527. XKeycodeToKeysym uses internal Xlib tables, which already
  21528. have converted alphabetic upper case to lowercase, and
  21529. returns the keysym defined for the specified keycode and the
  21530. element of the keycode vector.
  21531.  
  21532.  
  21533.  
  21534.                      December 18, 1987
  21535.  
  21536.  
  21537.  
  21538.  
  21539.  
  21540.                           - 315 -
  21541.  
  21542.  
  21543. Use XKeysymToKeycode to convert a keysym to the appropriate
  21544. keycode.  The definition for this function is:
  21545.  
  21546. KeyCode XKeysymToKeycode(display, keysym_kcode)
  21547.       Display *display;
  21548.       Keysym keysym_kcode;
  21549.  
  21550.  
  21551. display   Specifies the connection to the X server.
  21552.  
  21553. keysym_kcodeSpecifies the keysym that is to be searched for.
  21554.  
  21555. If the specified keysym is not defined for any keycode,
  21556. XKeysymToKeycode returns zero (0).
  21557.  
  21558. 10.1.2.  Keysym Classification Macros
  21559.  
  21560. You may want to test if a keysym of the defined set
  21561. (XK_MISCELLANY) is, for example, on the key pad or the func-
  21562. tion keys.  You can use the keysym macros to perform the
  21563. following tests.
  21564.  
  21565.  
  21566.  
  21567. IsKeypadKey(keysym)
  21568.  
  21569. Returns True if the keysym is on the key pad.
  21570.  
  21571.  
  21572.  
  21573. IsCursorKey(keysym)
  21574.  
  21575. Returns True if the keysyum is on the cursor key.
  21576.  
  21577.  
  21578.  
  21579. IsPFKey(keysym)
  21580.  
  21581. Returns True if the keysyum is on the PF keys.
  21582.  
  21583.  
  21584.  
  21585. IsFunctionKey(keysym)
  21586.  
  21587. Returns True if the keysyum is on the function keys.
  21588.  
  21589.  
  21590.  
  21591. IsMiscFunctionKey(keysym)
  21592.  
  21593. Returns True if the keysyum is on the miscellaneous function
  21594. keys.
  21595.  
  21596.  
  21597.  
  21598.  
  21599.  
  21600.                      December 18, 1987
  21601.  
  21602.  
  21603.  
  21604.  
  21605.  
  21606.                           - 316 -
  21607.  
  21608.  
  21609. IsModifierKey(keysym)
  21610.  
  21611. Returns True if the keysyum is on the modifier keys.
  21612.  
  21613. 10.2.  Obtaining the X Environment Defaults
  21614.  
  21615. A program often needs a variety of options in the X environ-
  21616. ment (for example, fonts, colors, mouse, background, text,
  21617. cursor).  Specifying these options on the command line is
  21618. inefficient and unmanageable because individual users have a
  21619. variety of tastes with regard to window appearance.  XGetDe-
  21620. fault makes it easy to find out the fonts, colors, and other
  21621. environment defaults favored by a particular user.  Defaults
  21622. are usually loaded onto a property on the root window at
  21623. login.  It merges any additional defaults from a file in the
  21624. user's home directory.  On a UNIX-based system, it uses
  21625. ~/.Xdefaults.  See the X manual page for details of its for-
  21626. mat.  This is a simple interface for clients not wishing to
  21627. use the X toolkit or the more elaborate interfaces provided
  21628. by the resource manager discussed in section 10.11.
  21629.  
  21630. The strings returned by XGetDefault are owned by Xlib and
  21631. should not be modified or freed by the client.  The defini-
  21632. tion for this function is:
  21633.  
  21634. char *XGetDefault(display, program, option)
  21635.       Display *display;
  21636.       char *program;
  21637.       char *option;
  21638.  
  21639.  
  21640. display   Specifies the connection to the X server.
  21641.  
  21642. program   Specifies the program name for the Xlib defaults.
  21643.           You must pass the program name in with the program
  21644.           argument (usually argv[0]).
  21645.  
  21646. option    Specifies the option name.
  21647.  
  21648. XGetDefault returns the value NULL if the option name speci-
  21649. fied in this argument does not exist for the program.
  21650.  
  21651. 10.3.  Parsing the Window Geometry
  21652.  
  21653. Xlib provides functions with which you can parse the window
  21654. geometry.
  21655.  
  21656.  
  21657. Use XParseGeometry to parse standard window geometry
  21658. strings. The definition for XParseGeometry is:
  21659.  
  21660.  
  21661.  
  21662.  
  21663.  
  21664.  
  21665.  
  21666.                      December 18, 1987
  21667.  
  21668.  
  21669.  
  21670.  
  21671.  
  21672.                           - 317 -
  21673.  
  21674.  
  21675. int XParseGeometry(parsestring, x_return, y_return, width_return, height_return)
  21676.       char *parsestring;
  21677.       int *x_return, *y_return;
  21678.       int *width_return, *height_return;
  21679.  
  21680.  
  21681. parsestringSpecifies the string you want to parse.
  21682.  
  21683. x_return
  21684. y_return  Returns the xoffset and yoffset determined.
  21685.  
  21686. width_return
  21687. height_returnReturn the width and height determined.
  21688.  
  21689. By convention, X applications use a standard string to indi-
  21690. cate window size and placement.  XParseGeometry makes it
  21691. easier to conform to this standard because it allows you to
  21692. parse the standard window geometry.  Specifically, this
  21693. function lets you parse strings of the form:
  21694.  
  21695.      =<width>x<height>{+-}<xoffset>{+-}<yoffset>
  21696.  
  21697. The items in this form map into the arguments associated
  21698. with this function.
  21699.  
  21700. The XParseGeometry function returns a bitmask that indicates
  21701. which of the four values (width, height, xoffset, and
  21702. yoffset) were actually found in the string and that indi-
  21703. cates whether the x and y values are negative. By conven-
  21704. tion, -0 is not equal to +0, because the user needs to be
  21705. able to say "position the window relative to the right or
  21706. bottom edge."  For each value found, the corresponding argu-
  21707. ment is updated.  For each value not found, the argument is
  21708. left unchanged.  The bits are represented by these con-
  21709. stants:  XValue, YValue, WidthValue, HeightValue, XNegative,
  21710. YNegative and are defined in <X11/Xutil.h>.  They will be
  21711. set whenever one of the values are defined or signs are set.
  21712.  
  21713. If the function returns either the XValue or YValue flag,
  21714. you should place the window at the requested position.  The
  21715. border width (bwidth), size of the increments width and
  21716. height (typically font width and height), and any additional
  21717. interior space (xadd and yadd) are passed in to make it easy
  21718. to compute the resulting size.  It is not normally used by
  21719. user programs, which typically use the XCreateWindow or
  21720. XCreateSimpleWindow function to create the window.
  21721.  
  21722.  
  21723. Use XGeometry to parse window geometry given an argument and
  21724. a default position. The definition for this function is:
  21725.  
  21726.  
  21727.  
  21728.  
  21729.  
  21730.  
  21731.  
  21732.                      December 18, 1987
  21733.  
  21734.  
  21735.  
  21736.  
  21737.  
  21738.                           - 318 -
  21739.  
  21740.  
  21741. int XGeometry(display, screen, position, default, bwidth, fwidth, fheight, xadder,
  21742.                   yadder, x_return, y_return, width_return, height_return)
  21743.       Display *display;
  21744.       int screen;
  21745.       char *position, *default;
  21746.       unsigned int bwidth;
  21747.       unsigned int fwidth, fheight;
  21748.       int xadder, yadder;
  21749.       int *x_return, *y_return;
  21750.         int *width_return, *height_return;
  21751.  
  21752.  
  21753. display   Specifies the connection to the X server.
  21754.  
  21755. screen    Specifies the screen.
  21756.  
  21757. position
  21758. default   Specify the geometry specifications.
  21759.  
  21760. bwidth    Specifies the border width.
  21761.  
  21762. fheight
  21763. fwidth    Specify the font height and width in pixels
  21764.           (increment size).
  21765.  
  21766. xadder
  21767. yadder    Specify additional interior padding needed in the
  21768.           window.
  21769.  
  21770. x_return
  21771. y_return  Returns the xoffset and yoffset determined.
  21772.  
  21773. width_return
  21774. height_returnReturn the width and height determined.
  21775.  
  21776. The XGeometry function returns the position the window
  21777. should be placed given a position and a default position.
  21778. XGeometry determines the placement of a window using the
  21779. current format to position windows.  Given a fully qualified
  21780. default geometry specification and, possibly, an incom-
  21781. pletely specified geometry specification, it will return a
  21782. bitmask value as defined above in the XParseGeometry call.
  21783.  
  21784. 10.4.  Parsing the Color Specifications
  21785.  
  21786. Use XParseColor to parse color values. The definition for
  21787. this function is:
  21788.  
  21789. Status XParseColor(display, cmap, spec, screen_def_return)
  21790.         Display *display;
  21791.         Colormap cmap;
  21792.         char *spec;
  21793.         XColor *screen_def_return;
  21794.  
  21795.  
  21796.  
  21797.  
  21798.                      December 18, 1987
  21799.  
  21800.  
  21801.  
  21802.  
  21803.  
  21804.                           - 319 -
  21805.  
  21806.  
  21807. display   Specifies the connection to the X server.
  21808.  
  21809. cmap      Specifies the color map ID.
  21810.  
  21811. spec      Specifies the color name string.  Uppercase and
  21812.           lowercase characters are acceptable.
  21813.  
  21814. screen_def_returnReturns the values actually used in the
  21815.           color map.
  21816.  
  21817. The XParseColor function provides a simple way to create a
  21818. standard user interface to color.  It takes a string specif-
  21819. ication of a color, typically from a command line or XGetDe-
  21820. fault option, and returns the corresponding red, green, and
  21821. blue values that are suitable for a subsequent call to XAl-
  21822. locColor or XStoreColor.  The color can be specified either
  21823. as a color name (as in XAllocNamedColor) or as an initial
  21824. sharp sign character following by a numeric specification,
  21825. in one of the following formats:
  21826.  
  21827.      #RGB                     (4 bits each)
  21828.      #RRGGBB                  (8 bits each)
  21829.      #RRRGGGBBB               (12 bits each)
  21830.      #RRRRGGGGBBBB            (16 bits each)
  21831.  
  21832. The R, G, and B represent single hexadecimal digits (upper
  21833. or lower case).  When fewer than 16 bits each are specified,
  21834. they represent the most significant bits of the value.  For
  21835. example, #3a7 is the same as #3000a0007000.  The colormap is
  21836. used only to determine which screen to look up the color on.
  21837. For example, you can use the screen's default colormap.
  21838.  
  21839. This routine will fail and return zero (0) status either if
  21840. the initial character is a sharp sign, but the string other-
  21841. wise fails to fit of the above formats, or if the initial
  21842. character is not a sharp sign and the named color does not
  21843. exist in the server's database.
  21844.  
  21845. The error that can be generated by XParseColor is BadColor.
  21846.  
  21847. 10.5.  Generating Regions
  21848.  
  21849. Regions are arbitrary collections of pixels.  Xlib provides
  21850. functions for manipulating regions.  The opaque type Region
  21851. is defined in <X11/Xutil.h>.
  21852.  
  21853.  
  21854. Use XPolygonRegion to generate a region from points. The
  21855. definition for this function is:
  21856.  
  21857. Region XPolygonRegion(n, points, fill_rule)
  21858.       int n;
  21859.       XPoint points[];
  21860.       int fill_rule;
  21861.  
  21862.  
  21863.  
  21864.                      December 18, 1987
  21865.  
  21866.  
  21867.  
  21868.  
  21869.  
  21870.                           - 320 -
  21871.  
  21872.  
  21873. n         Specifies the number of points in the polygon.
  21874.  
  21875. points    Specifies an array of points.
  21876.  
  21877. fill_rule Specifies the fill rule you want to set for the
  21878.           specified graphics context.  You can pass one of
  21879.           these constants:  EvenOddRule or WindingRule.
  21880.  
  21881. The XPolygonRegion function returns a region defined by the
  21882. points array.  See XCreateGC in Section 5.3 for an explana-
  21883. tion of fill_rule.
  21884.  
  21885.  
  21886. Use XClipBox to generate the smallest enclosing rectangle in
  21887. rect. The definition for this function is:
  21888.  
  21889. XClipBox(r, rect)
  21890.       Region r;
  21891.       XRectangle *rect;
  21892.  
  21893.  
  21894. r         Specifies the region.  This is the region in which
  21895.           the rectangle is located.
  21896.  
  21897. rect      Specifies the rectangle.  This is the rectangle in
  21898.           which the smallest enclosing rectangle is gen-
  21899.           erated.
  21900.  
  21901. The XClipBox function generates the smallest enclosing rec-
  21902. tangle in the specified rectangle that is located in the
  21903. specified region.
  21904.  
  21905. 10.6.  Manipulating Regions
  21906.  
  21907. Xlib provides functions with which you can manipulate
  21908. regions.  This section discusses how to:
  21909.  
  21910. o    Create, copy, or destroy regions
  21911.  
  21912. o    Move or shrink regions
  21913.  
  21914. o    Compute with regions
  21915.  
  21916. o    Determine if regions are empty or equal
  21917.  
  21918. o    Locate a point or rectangle in a region
  21919.  
  21920. 10.6.1.  Creating, Copying, or Destroying Regions
  21921.  
  21922. Xlib provides functions with which you can create, copy, or
  21923. destroy a region.
  21924.  
  21925.  
  21926. Use XCreateRegion to create a new empty region. The
  21927.  
  21928.  
  21929.  
  21930.                      December 18, 1987
  21931.  
  21932.  
  21933.  
  21934.  
  21935.  
  21936.                           - 321 -
  21937.  
  21938.  
  21939. definition for this function is:
  21940.  
  21941. Region XCreateRegion()
  21942.  
  21943.  
  21944.  
  21945. Use XSetRegion to set the graphics contexts to the specified
  21946. region. The definition for this function is:
  21947.  
  21948. XSetRegion(display, gc, r)
  21949.       Display *display;
  21950.       GC gc;
  21951.       Region r;
  21952.  
  21953.  
  21954. display   Specifies the connection to the X server.
  21955.  
  21956. gc        Specifies the graphics context.
  21957.  
  21958. r         Specifies the region.  This is the region in which
  21959.           you want to set the specified graphics context.
  21960.  
  21961. The XSetRegion function sets the clip mask in the graphics
  21962. contexts to the specified region.  Once is is set in the GC,
  21963. the region can be destroyed.
  21964.  
  21965.  
  21966. Use XDestroyRegion to deallocate the storage associated with
  21967. a specified region. The definition for this function is:
  21968.  
  21969. XDestroyRegion(r)
  21970.       Region r;
  21971.  
  21972.  
  21973. r         Specifies the region.
  21974.  
  21975. 10.6.2.  Moving or Shrinking Regions
  21976.  
  21977. Xlib provides functions with which you can move or shrink
  21978. regions.
  21979.  
  21980.  
  21981. Use XOffsetRegion to move the specified region by a speci-
  21982. fied amount. The definition for this function is:
  21983.  
  21984. XOffsetRegion(r, dx, dy)
  21985.       Region r;
  21986.       int dx, dy;
  21987.  
  21988.  
  21989. r         Specifies the region.
  21990.  
  21991.  
  21992.  
  21993.  
  21994.  
  21995.  
  21996.                      December 18, 1987
  21997.  
  21998.  
  21999.  
  22000.  
  22001.  
  22002.                           - 322 -
  22003.  
  22004.  
  22005. dx
  22006. dy        Specify the x and y coordinates.  These coordi-
  22007.           nates define the amount by which you want to move
  22008.           the specified region.
  22009.  
  22010.  
  22011. Use XShrinkRegion to reduce the specified region by a speci-
  22012. fied amount. The definition for this function is:
  22013.  
  22014. XShrinkRegion(r, dx, dy)
  22015.       Region r;
  22016.       int dx, dy;
  22017.  
  22018.  
  22019. r         Specifies the region.
  22020.  
  22021. dx
  22022. dy        Specify the x and y coordinates.  These coordi-
  22023.           nates define the amount by which you want to
  22024.           shrink the specified region.
  22025.  
  22026. Positive values shrink the size of the region, while nega-
  22027. tive values expand the region.
  22028.  
  22029. 10.6.3.  Computing with Regions
  22030.  
  22031. Xlib provides functions with which you can compute the
  22032. intersection, union, or results of two regions.
  22033.  
  22034.  
  22035. Use XIntersectRegion to compute the intersection of two
  22036. regions. The definition for this function is:
  22037.  
  22038. XIntersectRegion(sra, srb, dr)
  22039.       Region sra, srb, dr;
  22040.  
  22041.  
  22042. sra
  22043. srb       Specify the two regions with which you want to
  22044.           perform the computation.
  22045.  
  22046. dr        Stores the result of the computation.
  22047.  
  22048.  
  22049. Use XUnionRegion to compute the union of two regions. The
  22050. definition for this function is:
  22051.  
  22052. XUnionRegion(sra, srb, dr)
  22053.       Region sra, srb, dr;
  22054.  
  22055.  
  22056. sra
  22057.  
  22058.  
  22059.  
  22060.  
  22061.  
  22062.                      December 18, 1987
  22063.  
  22064.  
  22065.  
  22066.  
  22067.  
  22068.                           - 323 -
  22069.  
  22070.  
  22071. srb       Specify the two regions with which you want to
  22072.           perform the computation.
  22073.  
  22074. dr        Stores the result of the computation.
  22075.  
  22076.  
  22077. Use XSubtractRegion to subtract two regions. The definition
  22078. for this function is:
  22079.  
  22080. XSubtractRegion(sra, srb, dr)
  22081.       Region sra, srb, dr;
  22082.  
  22083.  
  22084. sra
  22085. srb       Specify the two regions with which you want to
  22086.           perform the computation.
  22087.  
  22088. dr        Stores the result of the computation.
  22089.  
  22090.  
  22091. Use XXorRegion to calculate the difference between the union
  22092. and intersection of two regions. The definition for this
  22093. function is:
  22094.  
  22095. XXorRegion(sra, srb, dr)
  22096.       Region sra, srb, dr;
  22097.  
  22098.  
  22099. sra
  22100. srb       Specify the two regions with which you want to
  22101.           perform the computation.
  22102.  
  22103. dr        Stores the result of the computation.
  22104.  
  22105. 10.6.4.  Determining If Regions Are Empty or Equal
  22106.  
  22107. Xlib provides functions with which you can determine if
  22108. regions are empty or equal.
  22109.  
  22110.  
  22111. Use XEmptyRegion to determine if the specified region is
  22112. empty. The definition for this function is:
  22113.  
  22114. int XEmptyRegion(r)
  22115.       Region r;
  22116.  
  22117.  
  22118. r         Specifies the region.
  22119.  
  22120. The XEmptyRegion function returns nonzero if the region is
  22121. empty.
  22122.  
  22123.  
  22124. Use XEqualRegion to determine if two regions have the same
  22125.  
  22126.  
  22127.  
  22128.                      December 18, 1987
  22129.  
  22130.  
  22131.  
  22132.  
  22133.  
  22134.                           - 324 -
  22135.  
  22136.  
  22137. offset, size, and shape. The definition for this function
  22138. is:
  22139.  
  22140. int XEqualRegion(r1, r2)
  22141.       Region r1, r2;
  22142.  
  22143.  
  22144. r1
  22145. r2        Specify the two regions.  These are the regions
  22146.           you want to determine have the same offset, size,
  22147.           and shape.
  22148.  
  22149. The XEqualRegion function returns nonzero if the two regions
  22150. are identical (that is, they have the same offset, size, and
  22151. shape).
  22152.  
  22153. 10.6.5.  Locating a Point or a Rectangle in a Region
  22154.  
  22155. Xlib provides functions with which you can determine if a
  22156. point or a rectangle is contained in a region.
  22157.  
  22158.  
  22159. Use XPointInRegion to determine if a specified point resides
  22160. in a specified region.  The definition for this function is:
  22161.  
  22162. int XPointInRegion(r, x, y)
  22163.       Region r;
  22164.       int x, y;
  22165.  
  22166.  
  22167. r         Specifies the region.
  22168.  
  22169. x
  22170. y         Specify the x and y coordinates.  These define the
  22171.           coordinates of the point.
  22172.  
  22173. The XPointInRegion function returns nonzero if the point x,
  22174. y is contained in the region r.
  22175.  
  22176.  
  22177. Use XRectInRegion to determine if a specified rectangle
  22178. resides in the specified region. The definition for this
  22179. function is:
  22180.  
  22181. int XRectInRegion(r, x, y, width, height)
  22182.       Region r;
  22183.       int x, y;
  22184.       unsigned int width, height;
  22185.  
  22186.  
  22187. r         Specifies the region.
  22188.  
  22189.  
  22190.  
  22191.  
  22192.  
  22193.  
  22194.                      December 18, 1987
  22195.  
  22196.  
  22197.  
  22198.  
  22199.  
  22200.                           - 325 -
  22201.  
  22202.  
  22203. x
  22204. y         Specify the x and y coordinates.  These define the
  22205.           coordinates of the point.
  22206.  
  22207. width
  22208. height    Specify the width and height.  These specify the
  22209.           rectangle in which you want to determine the point
  22210.           resides.
  22211.  
  22212. The XRectInRegion function returns RectangleIn if the rec-
  22213. tangle is entirely in the specified region, RectangleOut if
  22214. the rectangle is entirely out of the specified region, and
  22215. RectanglePart if the rectangle is partially in the specified
  22216. region.
  22217.  
  22218. 10.7.  Using the Cut and Paste Buffers
  22219.  
  22220. Xlib provides functions with which you can use cut and paste
  22221. buffers for programs using this form of communications.  See
  22222. also the sections on selections, which are a more useful
  22223. mechanism for interchanging data between clients, as typed
  22224. information can be exchanged.  X provides areas of memory in
  22225. which bytes can be stored for implementing cut and paste
  22226. between windows (implemented by use of properties on the
  22227. first root window of the display).  It is up to applications
  22228. to agree on how to represent the data in the buffers.  The
  22229. data is most often ISO Latin 1 text.  The atoms for eight
  22230. such buffers are provided, which can be accessed as a ring
  22231. or as explicit buffers (numbered 0 through 7).  These
  22232. buffers are typically used by either XYO applications or
  22233. Andrew applications.  We encourage new applications to share
  22234. data by using selections.  See Section 4.4 for further
  22235. information.
  22236.  
  22237.  
  22238. Use XStoreBytes to store data in cut buffer 0.  The defini-
  22239. tion for this function is:
  22240.  
  22241. XStoreBytes(display, bytes, nbytes)
  22242.       Display *display;
  22243.       char bytes[];
  22244.       int nbytes;
  22245.  
  22246.  
  22247. display   Specifies the connection to the X server.
  22248.  
  22249. bytes     Specifies the string of bytes you want stored.
  22250.           The byte string is not necessarily ASCII or null-
  22251.           terminated.
  22252.  
  22253. nbytes    Specifies the number of bytes of the bytes argu-
  22254.           ment that you want stored.
  22255.  
  22256. The XStoreBytes function returns the number of bytes to be
  22257.  
  22258.  
  22259.  
  22260.                      December 18, 1987
  22261.  
  22262.  
  22263.  
  22264.  
  22265.  
  22266.                           - 326 -
  22267.  
  22268.  
  22269. stored to the nbytes argument.  Note that the cut buffer's
  22270. contents need not be text, so null bytes are not special.
  22271. The cut buffer's contents may be retrieved later by any
  22272. client calling XFetchBytes.
  22273.  
  22274. The errors that can be generated by XStoreBytes are BadWin-
  22275. dow and BadAlloc.
  22276.  
  22277.  
  22278. Use XStoreBuffer to store data in a specified cut buffer.
  22279. The definition for this function is:
  22280.  
  22281. XStoreBuffer(display, bytes, nbytes, buffer)
  22282.       Display *display;
  22283.       char bytes[];
  22284.       int nbytes;
  22285.       int buffer;
  22286.  
  22287.  
  22288. display   Specifies the connection to the X server.
  22289.  
  22290. bytes     Specifies the string of bytes you want stored.
  22291.           The byte string is not necessarily ASCII or null-
  22292.           terminated.
  22293.  
  22294. nbytes    Specifies the number of bytes of the bytes argu-
  22295.           ment that you want stored.
  22296.  
  22297. buffer    Specifies the buffer in which you want to store
  22298.           the byte string.
  22299.  
  22300. The errors that can be generated by XStoreBuffer are BadWin-
  22301. dow, BadAtom, and BadAlloc.
  22302.  
  22303.  
  22304. Use XFetchBytes to return data from cut buffer 0.  The
  22305. definition for this function is:
  22306.  
  22307. char *XFetchBytes(display, nbytes_return)
  22308.       Display *display;
  22309.       int *nbytes_return;
  22310.  
  22311.  
  22312. display   Specifies the connection to the X server.
  22313.  
  22314. nbytes_returnReturns the number of bytes in the string in
  22315.           the buffer.  XFetchBytes returns the number of
  22316.           bytes in this argument.  If there is no data in
  22317.           the buffer, the value zero (0) is returned to this
  22318.           argument.
  22319.  
  22320. The XFetchBytes function returns the number of bytes in the
  22321. nbytes argument, if the buffer contains data.  Otherwise,
  22322. the function returns NULL and sets nbytes to 0.  The
  22323.  
  22324.  
  22325.  
  22326.                      December 18, 1987
  22327.  
  22328.  
  22329.  
  22330.  
  22331.  
  22332.                           - 327 -
  22333.  
  22334.  
  22335. XFetchBytes function returns the number of bytes in the
  22336. nbytes argument, if the buffer contains data.  Otherwise,
  22337. the function returns NULL and sets nbytes to zero (0).  The
  22338. appropriate amount of storage is allocated and the pointer
  22339. returned.  The client must free this storage when finished
  22340. with it by calling XFree.  (See Section 2.4 for further
  22341. information.)  Note that the cut buffer does not necessarily
  22342. contain text, so it may contain embedded null bytes and may
  22343. not terminate with a null byte.
  22344.  
  22345. The error that can be generated by XFetchBytes is BadWindow.
  22346.  
  22347.  
  22348. Use XFetchBuffer to return data from a specified cut buffer.
  22349. The definition for this function is:
  22350.  
  22351. char *XFetchBuffer(display, nbytes_return, return_buffer)
  22352.       Display *display;
  22353.       int *nbytes_return;
  22354.       int return_buffer;
  22355.  
  22356.  
  22357. display   Specifies the connection to the X server.
  22358.  
  22359. nbytes_returnReturns the number of bytes in the string in
  22360.           the buffer.
  22361.  
  22362. return_bufferSpecifies which buffer you want to stored data
  22363.           to be returned from.
  22364.  
  22365. The XFetchBuffer function returns the value zero (0) to the
  22366. nbytes argument if there is no data in the buffer.
  22367.  
  22368. The error that can be generated by XFetchBuffer is BadValue.
  22369.  
  22370.  
  22371. Use XRotateBuffers to rotate the cut buffers.  The defini-
  22372. tion for this function is:
  22373.  
  22374. XRotateBuffers(display, rotate)
  22375.       Display *display;
  22376.       int rotate;
  22377.  
  22378.  
  22379. display   Specifies the connection to the X server.
  22380.  
  22381. rotate    Specifies how much to rotate the cut buffer.
  22382.  
  22383. The XRotateBuffers function rotates the cut buffers, such
  22384. that buffer 0 becomes buffer n, buffer 1 becomes n+1 mod 8,
  22385. and so on.  This cut buffer numbering is global to the
  22386. display.  Note that XRotateBuffers will generate an error if
  22387. any of the eight buffer have not been created.
  22388.  
  22389.  
  22390.  
  22391.  
  22392.                      December 18, 1987
  22393.  
  22394.  
  22395.  
  22396.  
  22397.  
  22398.                           - 328 -
  22399.  
  22400.  
  22401. The errors that can be generated by XRotateBuffers are
  22402. BadWindow, BadAtom, and BadMatch.
  22403.  
  22404. 10.8.  Determining the Appropriate Visual
  22405.  
  22406. A single display may support multiple screens.  Each screen
  22407. can have several different visual types supported at dif-
  22408. ferent depths.  You can use the functions described in this
  22409. section to determine which visual to use for your applica-
  22410. tion.
  22411.  
  22412. The functions in this section use the XVisualInfo structure,
  22413. which can be found in <X11/Xutil.h>.
  22414.  
  22415. typedef struct {
  22416.      Visual *visual;
  22417.      VisualID visualid;
  22418.      int screen;
  22419.      unsigned int depth;
  22420.      int class;
  22421.      unsigned long red_mask;
  22422.      unsigned long green_mask;
  22423.      unsigned long blue_mask;
  22424.      int colormap_size;
  22425.      int bits_per_rgb;
  22426. } XVisualInfo;
  22427.  
  22428. The definitions used for the visual information mask
  22429. (vinfo_mask) are:
  22430.  
  22431. #define VisualNoMask          0x0
  22432. #define VisualIDMask          0x1
  22433. #define VisualScreenMask      0x2
  22434. #define VisualDepthMask       0x4
  22435. #define VisualClassMask       0x8
  22436. #define VisualRedMaskMask     0x10
  22437. #define VisualGreenMaskMask   0x20
  22438. #define VisualBlueMaskMask    0x40
  22439. #define VisualColormapSizeMask0x80
  22440. #define VisualBitsPerRGBMask  0x100
  22441. #define VisualAllMask         0x1FF
  22442.  
  22443.  
  22444. Use XGetVisualInfo to obtain a list of visual information
  22445. structures that match a specified template. The definition
  22446. for this function is:
  22447.  
  22448. XVisualInfo *XGetVisualInfo(display, vinfo_mask, vinfo_template, nitems_return)
  22449.       Display *display;
  22450.       long vinfo_mask;
  22451.       XVisualInfo *vinfo_template;
  22452.       int *nitems_return;
  22453.  
  22454.  
  22455.  
  22456.  
  22457.  
  22458.                      December 18, 1987
  22459.  
  22460.  
  22461.  
  22462.  
  22463.  
  22464.                           - 329 -
  22465.  
  22466.  
  22467. display   Specifies the connection to the X server.
  22468.  
  22469. vinfo_maskSpecifies the visual mask value.
  22470.  
  22471. vinfo_templateSpecifies the visual attributes that are to be
  22472.           used in matching the visual structures.
  22473.  
  22474. nitems_returnReturns the number of matching visual struc-
  22475.           tures.
  22476.  
  22477. The XGetVisualInfo function returns a list of visual struc-
  22478. tures that match the attributes specified by the template
  22479. argument.  If no visual structures match the template using
  22480. the specified vinfo_mask, XGetVisualInfo returns a NULL.
  22481. Use XFree to free the data returned by this function.  (See
  22482. Section 2.4 for further information.)
  22483.  
  22484.  
  22485. Use XMatchVisualInfo to obtain the visual information that
  22486. matches the specified depth and class of the screen. The
  22487. definition for this function is:
  22488.  
  22489. Status XMatchVisualInfo(display, screen, depth, class, vinfo_return)
  22490.       Display *display;
  22491.       int screen;
  22492.       int depth;
  22493.       int class;
  22494.       XVisualInfo *vinfo_return;
  22495.  
  22496.  
  22497. display   Specifies the connection to the X server.
  22498.  
  22499. screen    Specifies the screen.
  22500.  
  22501. depth     Specifies the depth of the screen.
  22502.  
  22503. class     Specifies the class of the screen.
  22504.  
  22505. vinfo_returnReturns the match visual information.
  22506.  
  22507. The XMatchVisualInfo function returns the visual information
  22508. for a visual that matches the specified depth and class for
  22509. a screen.  Because multiple visuals that match the specified
  22510. depth and class can exist, the exact visual chosen is unde-
  22511. fined.  If a visual is found, this function returns True,
  22512. and the information on the visual is returned to the vinfo
  22513. argument.  Otherwise, when a visual is not found, it returns
  22514. False.
  22515.  
  22516. 10.9.  Manipulating Images
  22517.  
  22518. Xlib provides several functions that perform basic opera-
  22519. tions on images.  All operations on images are defined using
  22520. an XImage structure, as defined in <X11/Xlib.h>.  Because
  22521.  
  22522.  
  22523.  
  22524.                      December 18, 1987
  22525.  
  22526.  
  22527.  
  22528.  
  22529.  
  22530.                           - 330 -
  22531.  
  22532.  
  22533. the number of different types of image formats can be very
  22534. large, this hides details of image storage properly from
  22535. applications.
  22536.  
  22537. This section describes the functions for generic operations
  22538. on images.  Manufacturers can provide very fast implementa-
  22539. tions of these for the formats frequently encountered on
  22540. their hardware.  These functions are neither sufficient nor
  22541. desirable to use for general image processing.  Rather, they
  22542. are here to provide minimal functions on screen format
  22543. images.  The basic operations for getting and putting images
  22544. are XGetImage and XPutImage.  See Chapter 6 for further
  22545. information about these functions.
  22546.  
  22547.                             Note
  22548.  
  22549.      The functions to read and write images to and from
  22550.      disk files are not, as yet, defined.  This whole
  22551.      section probably needs work and elaboration.
  22552.      Suggestions are gratefully solicited.
  22553.  
  22554. Most of the fields are defined in the core protocol to
  22555. specify hardware variants, bit and byte ordering you may
  22556. encounter across manufacturers.
  22557.  
  22558. The XImage structure describes an image as it exists in the
  22559. client's memory. The user may request that some of the
  22560. members such as height, width, and xoffset be changed when
  22561. the image is sent to the server (that is, the user may send
  22562. a subset of the image).  Other members (for example, byte
  22563. order, bitmap_unit, and so forth) are characteristics of
  22564. both the image and of the server. If these members differ
  22565. between the image and the server, XPutImage makes the
  22566. appropriate conversions.  See Chapter 6 for information
  22567. about XPutImage.  If the image is formatted as an XYPixmap,
  22568. that is the format member is set to the constant XYPixmap,
  22569. the first byte of the first line of plane n must be located
  22570. at the address (data + (n * height * bytes_per_line)).
  22571.  
  22572.  
  22573. Use XCreateImage to allocate sufficient memory for an XImage
  22574. structure.  The definition for this function is:
  22575.  
  22576.  
  22577.  
  22578.  
  22579.  
  22580.  
  22581.  
  22582.  
  22583.  
  22584.  
  22585.  
  22586.  
  22587.  
  22588.  
  22589.  
  22590.                      December 18, 1987
  22591.  
  22592.  
  22593.  
  22594.  
  22595.  
  22596.                           - 331 -
  22597.  
  22598.  
  22599. XImage *XCreateImage(display, visual, depth, format, offset, data, width, height, bitmap_pad,
  22600.                         bytes_per_line)
  22601.       Display *display;
  22602.       Visual *visual;
  22603.       unsigned int depth;
  22604.       int format;
  22605.       int offset;
  22606.       char *data;
  22607.       unsigned int width;
  22608.       unsigned int height;
  22609.       int bitmap_pad;
  22610.       int bytes_per_line;
  22611.  
  22612.  
  22613. display   Specifies the connection to the X server.
  22614.  
  22615. visual    Specifies a pointer to the visual.
  22616.  
  22617. depth     Specifies the depth of the image.
  22618.  
  22619. format    Specifies the format for the image.  You can pass
  22620.           one of these constants:  XYPixmap or ZPixmap.
  22621.  
  22622. offset    Specifies the number of pixels to ignore at the
  22623.           beginning of the scanline.  This permits the rapid
  22624.           displaying of the image without requiring each
  22625.           scanline to be shifted into position.
  22626.  
  22627.  
  22628. data      Specifies a pointer to the image data.
  22629.  
  22630. width     Specifies the width (in pixels) of the image.
  22631.  
  22632. height    Specifies the height (in pixels) of the image.
  22633.  
  22634. bitmap_padSpecifies the quantum of a scanline.  In other
  22635.           words, the start of one scanline is separated in
  22636.           client memory from the start of the next scanline
  22637.           by an integer multiple of this many bits. You must
  22638.           pass one of these values: 8, 16, or 32.
  22639.  
  22640. bytes_per_lineSpecifies the number of bytes in the client
  22641.           image between the start of one scanline and the
  22642.           start of the next. If you pass a zero (0) value,
  22643.           Xlib assumes that the scanlines are contiguous in
  22644.           memory and calculates the value of bytes_per_line
  22645.           itself.
  22646.  
  22647. The XCreateImage function allocates the memory needed for an
  22648. XImage structure for the specified display.  This function
  22649. does not allocate space for the image itself.  Rather, it
  22650. initializes the structure with ``default'' values and
  22651. returns a pointer to the XImage structure.  The red, green,
  22652. and blue mask values are defined for Z format images only
  22653.  
  22654.  
  22655.  
  22656.                      December 18, 1987
  22657.  
  22658.  
  22659.  
  22660.  
  22661.  
  22662.                           - 332 -
  22663.  
  22664.  
  22665. and are derived from the Visual structure passed in.
  22666.  
  22667. The basic functions used to get a pixel, set a pixel, create
  22668. a subimage, and add a constant offset to a Z format image
  22669. are defined in the image object.  The macros to call through
  22670. the image object are defined in <X11/Xutil.h>.
  22671.  
  22672.  
  22673. Use XGetPixel to obtain a pixel value in an image.  The
  22674. definition for this function is:
  22675.  
  22676. unsigned long XGetPixel(ximage, x, y)
  22677.       XImage *ximage;
  22678.       int x;
  22679.       int y;
  22680.  
  22681.  
  22682. ximage    Specifies a pointer to the image.
  22683.  
  22684. x
  22685. y         Specify the x and y coordinates.
  22686.  
  22687. The XGetPixel function returns the specified pixel from the
  22688. named image.  The X and Y coordinates are relative to the
  22689. origin (upper left [0,0]) of the image.  The pixel value is
  22690. returned in normalized format (that is, the least signifi-
  22691. cant byte of the long is the least significant byte of the
  22692. pixel).
  22693.  
  22694.  
  22695. Use XPutPixel to set a pixel value in an image.  The defini-
  22696. tion for this function is:
  22697.  
  22698. int XPutPixel(ximage, x, y, pixel)
  22699.       XImage *ximage;
  22700.       int x;
  22701.       int y;
  22702.       unsigned long pixel;
  22703.  
  22704.  
  22705. ximage    Specifies a pointer to the image.
  22706.  
  22707. x
  22708. y         Specify the x and y coordinates.
  22709.  
  22710. pixel     Specifies the new pixel value.
  22711.  
  22712. The XPutPixel function overwrites the pixel in the named
  22713. image with the specified pixel value.  The X and Y coordi-
  22714. nates are relative to the origin (upper left [0,0]) of the
  22715. image.  The input pixel value must be in normalized format.
  22716. That is, the least significant byte of the long is the least
  22717. significant byte of the pixel.
  22718.  
  22719.  
  22720.  
  22721.  
  22722.                      December 18, 1987
  22723.  
  22724.  
  22725.  
  22726.  
  22727.  
  22728.                           - 333 -
  22729.  
  22730.  
  22731. Use XSubImage to create a subimage.  The definition for this
  22732. function is:
  22733.  
  22734. XImage *XSubImage(ximage, x, y, subimage_width, subimage_height)
  22735.       XImage *ximage;
  22736.       int x;
  22737.       int y;
  22738.       int subimage_width;
  22739.       int subimage_height;
  22740.  
  22741.  
  22742. ximage    Specifies a pointer to the image.
  22743.  
  22744. x
  22745. y         Specify the x and y coordinates.
  22746.  
  22747. subimage_widthSpecifies the width (in pixels) of the new
  22748.           subimage.
  22749.  
  22750. subimage_heightSpecifies the height (in pixel) of the new
  22751.           subimage.
  22752.  
  22753. The XSubImage function creates a new image that is a subsec-
  22754. tion of an existing one.  It allocates the memory necessary
  22755. for the new XImage structure and returns a pointer to the
  22756. new image.  The algorithm used is repetitive calls to XGet-
  22757. Pixel and XPutPixel.  Therefore, this function may be very
  22758. slow.
  22759.  
  22760.  
  22761. Use XAddPixel to increment each pixel in the pixmap by a
  22762. constant value.  The definition for this function is:
  22763.  
  22764. int XAddPixel(ximage, value)
  22765.       XImage *ximage;
  22766.       int value;
  22767.  
  22768.  
  22769. ximage    Specifies a pointer to the image.
  22770.  
  22771. value     Specifies the constant value that is to be added.
  22772.  
  22773. The XAddPixel function adds a constant value to every pixel
  22774. in an image.  This function is very useful when you have a
  22775. base pixel value from allocating color resources and need to
  22776. manipulate the image to that form.
  22777.  
  22778.  
  22779. Use XDestroyImage to deallocate the memory allocated in a
  22780. previous call to XCreateImage.  The definition for this
  22781. function is:
  22782.  
  22783. int XDestroyImage(ximage)
  22784.         XImage *ximage;
  22785.  
  22786.  
  22787.  
  22788.                      December 18, 1987
  22789.  
  22790.  
  22791.  
  22792.  
  22793.  
  22794.                           - 334 -
  22795.  
  22796.  
  22797. ximage    Specifies a pointer to the image.
  22798.  
  22799. The XDestroyImage function deallocates the memory associated
  22800. with the XImage
  22801.  
  22802. 10.10.  Manipulating Bitmaps
  22803.  
  22804. Xlib provides functions with which you can read a bitmap
  22805. from a file, save a bitmap to a file, or create a bitmap.
  22806. This section describes those functions that transfer bitmaps
  22807. to and from the client's file system, thus allowing their
  22808. reuse in a later connection (for example, from an entirely
  22809. different client or to a different display or server).
  22810.  
  22811.  
  22812. Use XReadBitmapFile to read a bitmap in from disk. The
  22813. definition for this function is:
  22814.  
  22815. int XReadBitmapFile(display, d, filename, width_return, height_return, bitmap_return, x_hot_return,
  22816.                        y_hot_return)
  22817.       Display *display;
  22818.       Drawable d;
  22819.       char *filename;
  22820.       int *width_return, *height_return;
  22821.       Pixmap *bitmap_return;
  22822.       int *x_hot_return, *y_hot_return;
  22823.  
  22824.  
  22825. display   Specifies the connection to the X server.
  22826.  
  22827. d         Specifies the drawable.
  22828.  
  22829. filename  Specifies the file name to use.  The format of the
  22830.           file name is operating system specific.
  22831.  
  22832. width_return
  22833. height_returnReturns the width and height values of the read
  22834.           in bitmap file.
  22835.  
  22836. bitmap_returnReturns the bitmap ID that is created.
  22837.  
  22838. x_hot_return
  22839. y_hot_returnReturns the hot spot coordinates.
  22840.  
  22841. The XReadBitmapFile function reads in a file containing a
  22842. bitmap.  The file can be either in the standard X version 10
  22843. format (that is, the format used by X version 10 bitmap pro-
  22844. gram) or in the newer X version 11 bitmap format.  If the
  22845. file cannot be opened, XReadBitmapFile returns BitmapOpen-
  22846. Failed.  If the file can be opened but does not contain
  22847. valid bitmap data, XReadBitmapFile returns BitmapFileIn-
  22848. valid.  If insufficient working storage is allocated, XRead-
  22849. BitmapFile returns BitmapNoMemory.  If the file is readable
  22850. and valid, XReadBitmapFile returns BitmapSuccess.
  22851.  
  22852.  
  22853.  
  22854.                      December 18, 1987
  22855.  
  22856.  
  22857.  
  22858.  
  22859.  
  22860.                           - 335 -
  22861.  
  22862.  
  22863. XReadBitmapFile assigns the bitmap's height and width, as
  22864. read from the file, to the caller's variables width and
  22865. height. It then creates a pixmap of the appropriate size,
  22866. reads the bitmap data from the file into the pixmap and
  22867. assigns the pixmap to the caller's variable bitmap. The
  22868. caller must free the bitmap using XFreePixmap when done.  If
  22869. x_hot and y_hot are non-NULL, XReadBitmapFile sets *x_hot
  22870. and *y_hot to the value of the hot spot as defined in the
  22871. file.  If no hot spot is defined, XReadBitmapFile sets
  22872. *x_hot and *y_hot to -1,-1.
  22873.  
  22874.  
  22875. Use XWriteBitmapFile to write out a bitmap to a file. The
  22876. definition for this function is:
  22877.  
  22878. int XWriteBitmapFile(display, filename, bitmap, width, height, x_hot, y_hot)
  22879.       Display *display;
  22880.       char *filename;
  22881.       Pixmap bitmap;
  22882.       int width, height;
  22883.       int x_hot, y_hot;
  22884.  
  22885.  
  22886. display   Specifies the connection to the X server.
  22887.  
  22888. filename  Specifies the file name to use.  The format of the
  22889.           file name is operating system specific.
  22890.  
  22891. bitmap    Specifies the bitmap to be written.
  22892.  
  22893. width
  22894. height    Specify the width and height.  These are the
  22895.           dimensions of the bitmap to be written.
  22896.  
  22897. x_hot
  22898. y_hot     Specifies where to place the hot spot coordinates
  22899.           (or -1,-1 if none are present) in the file.
  22900.  
  22901. The XWriteBitmapFile function writes a bitmap out to a file.
  22902. The file is written out in X version 11 bitmap format, which
  22903. is the format used by the X version 11 bitmap program. Refer
  22904. to that program's man pages for details. While XReadBitmap-
  22905. File can read in either X version 10 format or X version 11
  22906. format, XWriteBitmapFile always writes out X version 11 for-
  22907. mat only.  If the file cannot be opened for writing, XWri-
  22908. teBitmapFile returns BitmapOpenFailed.  If insufficient
  22909. memory is allocated XWriteBitmapFile returns BitmapNoMemory.
  22910. Otherwise, on no error, XWriteBitmapFile returns BitmapSuc-
  22911. cess.  If x_hot and y_hot are not -1, -1, XWriteBitmapFile
  22912. writes them out as the hot spot coordinates for the bitmap.
  22913.  
  22914.  
  22915. Use XCreateBitmapFromData to include a bitmap written out by
  22916. XWriteBitmapFile in a program directly, as opposed to
  22917.  
  22918.  
  22919.  
  22920.                      December 18, 1987
  22921.  
  22922.  
  22923.  
  22924.  
  22925.  
  22926.                           - 336 -
  22927.  
  22928.  
  22929. reading it in every time at run time.  The definition for
  22930. this function is:
  22931.  
  22932. Pixmap XCreateBitmapFromData(display, d, data, width, height)
  22933.       Display *display;
  22934.       Drawable d;
  22935.       char *data;
  22936.       int width, height;
  22937.  
  22938.  
  22939. display   Specifies the connection to the X server.
  22940.  
  22941. d         Specifies the drawable.
  22942.  
  22943. data      Specifies the location of the bitmap data.
  22944.  
  22945. width
  22946. height    Specify the width and height.  These are the
  22947.           dimensions of the bitmap to create.
  22948.  
  22949. The XCreateBitmapFromData function allows you to include in
  22950. your C program (using #include) a bitmap file that was writ-
  22951. ten out by XWriteBitmapFile (X version 11 format only) and,
  22952. without reading in the bitmap file, The following is an
  22953. example of getting a gray bitmap:
  22954.  
  22955. #include "gray.bitmap"
  22956. Pixmap XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);
  22957.  
  22958. If insufficient working storage was allocated, XCreateBit-
  22959. mapFromData returns NULL.  It is the user's responsibly to
  22960. free the bitmap using XFreePixmap when done.  Resource
  22961. Manager
  22962.  
  22963. 10.11.  Using the Resource Manager
  22964.  
  22965.                             Note
  22966.  
  22967.      Currently, for the first MIT release, the greatest
  22968.      user of the resource manager is the X Toolkit,
  22969.      which is running approximately a release cycle
  22970.      behind the Xlib and the server.  The interfaces
  22971.      described in this section are believed accurate
  22972.      and final.  However, for this release, the
  22973.      resource manager is packaged as a separate
  22974.      library, called ``Xrm''.
  22975.  
  22976.  
  22977. The resource manager essentially is a database manager.
  22978. Definitions for its use are contained in the
  22979. <X11/Xresource.h> header file.
  22980.  
  22981. Consider an X-based mail reading application called xmail.
  22982. Further assume that it is designed in such a manner that it
  22983.  
  22984.  
  22985.                      December 18, 1987
  22986.  
  22987.  
  22988.  
  22989.  
  22990.  
  22991.                           - 337 -
  22992.  
  22993.  
  22994. uses a complex window hierarchy, all the way down to indivi-
  22995. dual command buttons which are actually small subwindows.
  22996. If each window is properly assigned a name and class, it
  22997. becomes easy for the user to specify attributes of any por-
  22998. tion of the application.
  22999.  
  23000. At the top level, it might consist of a paned window. One
  23001. pane of the paned window is a button box window of command
  23002. buttons, named toc. One of these command buttons is used to
  23003. include (fetch) new mail. This window has a name
  23004. ``xmail.toc.buttons.include'' and a class
  23005. ``application.panelwindow.buttonbox.commandButton''.  Its
  23006. name is the name of its parent, ``xmail.toc.buttons'', fol-
  23007. lowed by its name ``include''. Its class is the class of its
  23008. parent, ``Application.Panelwindow.Buttonbox'', followed by
  23009. its particular class, ``CommandButton''.  The fully quali-
  23010. fied name of an attribute is its name appended to the window
  23011. name, and its class is its class appended to the window
  23012. class.
  23013.  
  23014. This button needs the following resources:
  23015.  
  23016. o    Title string
  23017.  
  23018. o    Font
  23019.  
  23020. o    Foreground color
  23021.  
  23022. o    Background color
  23023.  
  23024. o    Foreground color for its active state
  23025.  
  23026. o    Background color for its active state
  23027.  
  23028. Each of the resources that this button needs are considered
  23029. to be attributes of the button and, as such, have a name and
  23030. a class. For example, the foreground color for the button in
  23031. its active state might be named ``activeForeground'' and its
  23032. class would be ``Color.''
  23033.  
  23034. When a window requests a resource (for example, a color), it
  23035. passes the complete name and class of the resource along
  23036. with the desired representation type to a lookup routine.
  23037. The representation type lets a window request different
  23038. representations for the same resource. For example, a color
  23039. might be requested as a color record, a pixel, a pixmap, or
  23040. a name string. Rather than require the application to store
  23041. every possible representation of a resource, Xlib provides a
  23042. mechanism for converting between representations.
  23043.  
  23044. The interface is implemented in two layers. The top layer
  23045. allows applications to store resources by name, class, and
  23046. representation type, as well as to retrieve them given a
  23047. fully qualified name, class, and destination representation.
  23048.  
  23049.  
  23050.  
  23051.                      December 18, 1987
  23052.  
  23053.  
  23054.  
  23055.  
  23056.  
  23057.                           - 338 -
  23058.  
  23059.  
  23060. The resource manager automatically calls a conversion rou-
  23061. tine, if necessary and possible, to convert the stored
  23062. representation to the destination representation.
  23063.  
  23064. This layer is built on top of a primitive manager that pro-
  23065. vides the ability to store entries by name and class and a
  23066. way of retrieving these values given a full name and class.
  23067. This layer stores uninterpreted variable length values and
  23068. has no knowledge of resource representations.
  23069.  
  23070. The algorithm for determining which resource name or names
  23071. match a given query is the heart of the database.  The idea
  23072. is that resources are stored with only partially specified
  23073. name and classes. The unspecified portions of the name match
  23074. any part of a more completely specified name or class. In
  23075. particular, all queries fully specify the name and class of
  23076. the resource needed.  The lookup algorithm then searches the
  23077. database for the name that most closely matches this full
  23078. name and class.  The definition of a match is as follows:
  23079.  
  23080. For a query of name N = n1.n2.n3...nk and class C =
  23081. c1.c2.c3...ck, a partial name P = p1.p2.p3...pm matches
  23082. (N,C), if P matches the regular expression [n1|c1] [n2|c2]
  23083. [n3|c3]...[nk|ck]. The regular expression ``a|b'' matches
  23084. either ``a'' or ``b'', ``[a]'' matches ``a'' or NULL (that
  23085. is, ``a'' is optional), and ``a b'' matches ``a'' followed
  23086. by ``b''.  As they are defined, the name and the class have
  23087. exactly the same number of components.
  23088.  
  23089. If two distinct partial names P and Q both match (N,C), then
  23090. the rule for establishing precedence is defined below.  For
  23091. P, construct a k element list (X = x1, x2, x3...xk).  If ni
  23092. is an element of P, then xi = 2.  If ci is an element of P,
  23093. then xi = 1.  If any other case occurs, xi = 0.
  23094.  
  23095. Construct a similar k element list for Q (Y = y1, y2,
  23096. y3...yk).  Compare X and Y by comparing the values of x1 and
  23097. y1.  If they are equal, compare x2 and y2, and so on.  If X
  23098. > Y, then the partial name P takes precedence over the par-
  23099. tial name Q.
  23100.  
  23101. For example, assume the following user preference specifica-
  23102. tion:
  23103.  
  23104.         xmail.background:        red
  23105.         button.font:             Helv10
  23106.         button.background:       blue
  23107.         button.color:            green
  23108.         xmail.toc.button.activeForeground:black
  23109.         xmail.toc.buttons.border:3
  23110.  
  23111.  
  23112. A query for the name
  23113. ``xmail.toc.button.include.activeForeground'' and class
  23114.  
  23115.  
  23116.  
  23117.                      December 18, 1987
  23118.  
  23119.  
  23120.  
  23121.  
  23122.  
  23123.                           - 339 -
  23124.  
  23125.  
  23126. ``application.panelwindow.buttonbox.button.color'' matches
  23127. ``xmail.toc.button.activeForeground'' and returns ``black''.
  23128. However, it also matches ``button.color''.
  23129.  
  23130. Using the precedence algorithm described above indicates
  23131. that the ``xmail.toc.button.activeForeground'' specification
  23132. is the one that ``wins''.
  23133.  
  23134. Database values consist of a size and an address. The size
  23135. is specified in machine dependent units, while the address
  23136. is a machine-dependent pointer to uninterpreted machine
  23137. memory, for example:
  23138.  
  23139. typedef  void (*XrmTypeConverter)();
  23140.  
  23141. The type conversion machinery calls conversion procedures to
  23142. convert between differing resource representations. There
  23143. are some predefined conversions, but clients can register as
  23144. many new conversions as are needed. These registered conver-
  23145. sion procedures have a type of XrmTypeConverter. They take a
  23146. source type and value. Then, they convert them to a destina-
  23147. tion type and value. There is a string (atom) for each
  23148. defined resource representation type, and the values are
  23149. size and address pairs. See XrmRegisterTypeConverter and
  23150. XrmConvert for further information.
  23151.  
  23152. A resource database is an opaque structure used by the
  23153. lookup routines.
  23154.  
  23155. typedef struct ResourceDataBaseStruct *ResourceDataBase;
  23156.  
  23157. See XrmGetDataBase, XrmPutDataBase, and XrmMergeDataBases
  23158. for further information.
  23159.  
  23160. Xlib provides resource management functions with which you
  23161. can manipulate the resource manager.  The following sections
  23162. discuss how to:
  23163.  
  23164. o    Store and get resources
  23165.  
  23166. o    Getting database levels
  23167.  
  23168. o    Convert resource values
  23169.  
  23170. o    Merge the resource database
  23171.  
  23172. o    Retrieve and store databases
  23173.  
  23174. 10.11.1.  Storing and Getting Resources
  23175.  
  23176. Use XrmPutResource to store a resource in the database. The
  23177. definition for this function is:
  23178.  
  23179.  
  23180.  
  23181.  
  23182.  
  23183.                      December 18, 1987
  23184.  
  23185.  
  23186.  
  23187.  
  23188.  
  23189.                           - 340 -
  23190.  
  23191.  
  23192. void XrmPutResource(db, list, data_type, value_descriptor)
  23193.       XrmResourceDataBase *db;
  23194.       XrmQuarkList list;
  23195.       XrmRepresentation data_type;
  23196.       XrmValuePtr value_descriptor;
  23197.  
  23198.  
  23199. db        Specifies the descriptor of the resource database.
  23200.  
  23201. list      Specifies the partial name or class list of the
  23202.           resource to be stored.
  23203.  
  23204. data_type Specifies the data representation of the resource
  23205.           to be stored.
  23206.  
  23207. value_descriptorSpecifies the descriptor for the resource
  23208.           entry.
  23209.  
  23210. The XrmPutResource function takes a partial name, a
  23211. representation type, and a value.  The value is copied into
  23212. the specified database db.
  23213.  
  23214.  
  23215. Use XrmGetResource to retrieve a resource from the database.
  23216. The definition for this function is:
  23217.  
  23218. void XrmGetResource(screen, db, inher_name, inher_class, type, value_return)
  23219.       Screen screen;
  23220.       XrmResourceDataBase *db;
  23221.       XrmNameList inher_name;
  23222.       XrmClassList inher_class;
  23223.       XrmRepresentation type;
  23224.       XrmValuePtr *value_return;
  23225.  
  23226.  
  23227. screen    Specifies the screen that is to be used for the
  23228.           lookup.
  23229.  
  23230. db        Specifies the descriptor of the resource database.
  23231.  
  23232. inher_nameSpecifies the full inheritance name of the value
  23233.           being retrieved.
  23234.  
  23235. inher_classSpecifies the full inheritance class of the value
  23236.           being retrieved.
  23237.  
  23238. type      Specifies the representation type of the destina-
  23239.           tion.
  23240.  
  23241. value_returnReturns the value, which represents a database
  23242.           address.
  23243.  
  23244. The XrmGetResource function retrieves a resource from the
  23245. database.  It takes a full name/class pair, a destination
  23246.  
  23247.  
  23248.  
  23249.                      December 18, 1987
  23250.  
  23251.  
  23252.  
  23253.  
  23254.  
  23255.                           - 341 -
  23256.  
  23257.  
  23258. resource representation, and the address of a value
  23259. (size/address pair).  The value returned points into data-
  23260. base memory.  The value returned points into database
  23261. memory. Therefore, the client should copy it to be safe.
  23262. Currently, the database only frees or overwrites entries on
  23263. XrmPutResource or XrmMergeDataBases.  A client that is not
  23264. doing any XrmPutResources or that is not merging the data-
  23265. base should be safe using the address passed back.
  23266.  
  23267. 10.11.2.  Getting Database Levels
  23268.  
  23269. Some applications and toolkits do not make random probes
  23270. into the database to fetch resources.  The toolkit access
  23271. pattern for the database is quite stylized:  a series of
  23272. from one to twenty probes are made with only the last
  23273. name/class differing in each probe.  The XrmGetResource is
  23274. at worst a 2^n algorithm (n is the length of the name/class
  23275. list).
  23276.  
  23277.  
  23278. Use XrmGetSearchList to return a list of database levels.
  23279. The definition for this function is:
  23280.  
  23281. void XrmGetSearchList(names, classes, list)
  23282.       XrmNameList  names;
  23283.       XrmClassList classes;
  23284.       XrmSearchList ist;
  23285.  
  23286.  
  23287. names     Specifies a list of resource names.
  23288.  
  23289. classes   Specifies a list of resource classes.
  23290.  
  23291. list      Specifies an argument to which the list of data-
  23292.           base levels is returned.
  23293.  
  23294. The XrmGetSearchList function takes a list of names and
  23295. classes and returns a list of database levels where a match
  23296. might occur.  The returned list is a best-to-worst order and
  23297. uses the same algorithm as XrmGetResource for determining
  23298. precedence.
  23299.  
  23300.  
  23301. Use XrmGetSearchResource to search the database levels for a
  23302. given resource.  The definition for this function is:
  23303.  
  23304. XGetSearchResource(screen, list, name, class, type, value)
  23305.       Screen *screen;
  23306.       XrmSearchList list;
  23307.       XrmName name;
  23308.       XrmClass class;
  23309.       XrmAtom type;
  23310.       XrmValuePtr value;
  23311.  
  23312.  
  23313.  
  23314.  
  23315.                      December 18, 1987
  23316.  
  23317.  
  23318.  
  23319.  
  23320.  
  23321.                           - 342 -
  23322.  
  23323.  
  23324. screen    Specifies the screen.
  23325.  
  23326. list      Specifies the list of database levels that are to
  23327.           be searched.
  23328.  
  23329. name      Specifies the resource name.
  23330.  
  23331. class     Specifies the resource class.
  23332.  
  23333. type      Specifies data representation type.
  23334.  
  23335. values    Specifies a pointer to which the matched resource
  23336.           is returned.
  23337.  
  23338. The XrmGetSearchResource function searches the specified
  23339. database levels for the resource that is fully identified by
  23340. the specified name and class.  If it finds the resource,
  23341. XrmGetSearchResource first converts it to the specified type
  23342. and then returns this converted resource to the value argu-
  23343. ment.  The search stops with the first match.  If it does
  23344. not find the resource, XrmGetSearchResource returns NULL.
  23345.  
  23346. 10.11.3.  Converting Resource Values
  23347.  
  23348. Use XrmConvert to convert a value from one representation to
  23349. another. For example, a client might want to convert the
  23350. string ``blue'' to a pixel that will appear blue on a given
  23351. screen.  The predefined types can be found in
  23352. <X11/Xresource.h>.  The definition for this function is:
  23353.  
  23354. void XrmConvert(screen, from_type_convert, from, to_type_convert, to)
  23355.       Screen screen;
  23356.       XrmAtom from_type_convert;
  23357.       XrmValuePtr from;
  23358.       XrmAtom to_type_convert;
  23359.       XrmValuePtr to;
  23360.  
  23361.  
  23362. screen    Specifies the screen that is to be used for the
  23363.           conversion.
  23364.  
  23365. from_type_convertSpecifies the string (atom) describing the
  23366.           type to be converted.
  23367.  
  23368. from      Specifies the typed value descriptor for the type
  23369.           to be converted.
  23370.  
  23371. to_type_convertSpecifies the string (atom) describing the
  23372.           type desired.
  23373.  
  23374. to        Specifies the descriptor that is to receive the
  23375.           converted value.
  23376.  
  23377.  
  23378.  
  23379.  
  23380.  
  23381.                      December 18, 1987
  23382.  
  23383.  
  23384.  
  23385.  
  23386.  
  23387.                           - 343 -
  23388.  
  23389.  
  23390. Use XrmRegisterTypeConverter to extend the resource manager
  23391. conversion mechanism. The definition for this function is:
  23392.  
  23393. void XrmRegisterTypeConverter(from_type, to_type, proc)
  23394.       XrmAtom from_type, to_type;
  23395.       XrmTypeConverter proc;
  23396.  
  23397.  
  23398. from_type Specifies the source value type.
  23399.  
  23400. to_type   Specifies the destination value type.
  23401.  
  23402. proc      Specifies the conversion procedure used to convert
  23403.           the value.
  23404.  
  23405. The XrmRegisterTypeConverter function allows clients to
  23406. extend the mechanism by which the resource manager converts
  23407. between representations.  This is especially useful for
  23408. those clients who wish to extend the known representation
  23409. types.  If there is no conversion from the source type to
  23410. the destination type, then NULLs are returned for the desti-
  23411. nation size and address. This procedure is used by the
  23412. higher-level resource manager to implement XrmGetResource.
  23413.  
  23414. The converters themselves have the following calling
  23415. sequence:
  23416.  
  23417. void yourTypeConverter(screen, from_value, to_value_return)
  23418.       Screen *screen;
  23419.       XrmValuePtr from_value;
  23420.       XrmValuePtr to_value_return;
  23421.  
  23422.  
  23423. screen    Specifies that the conversion is performed rela-
  23424.           tive to the specified screen.
  23425.  
  23426. from_valueSpecifies the value to be converted.
  23427.  
  23428. to_value_returnReturns the value after the conversion.
  23429.  
  23430. Your conversion routine should convert the from_value to the
  23431. target type.
  23432.  
  23433. 10.11.4.  Merging Resource Databases
  23434.  
  23435. Use XrmMergeDataBases to merge the contents of one database
  23436. into another. The definition for this function is:
  23437.  
  23438. void XrmMergeDataBases(new, into)
  23439.       XrmResourceDataBase new, *into;
  23440.  
  23441.  
  23442.  
  23443.  
  23444.  
  23445.  
  23446.  
  23447.                      December 18, 1987
  23448.  
  23449.  
  23450.  
  23451.  
  23452.  
  23453.                           - 344 -
  23454.  
  23455.  
  23456. new       Specifies the descriptor of the resource database
  23457.           to be merged into the existing database.
  23458.  
  23459. into      Specifies the descriptor of the resource database
  23460.           into which the new database will be merged.
  23461.  
  23462. The XrmMergeDataBases function may overwrite entries in the
  23463. destination database. This procedure is used to combine
  23464. databases (for example, an application specific database of
  23465. defaults and a database of user preferences).
  23466.  
  23467. 10.11.5.  Retrieving and Storing Databases
  23468.  
  23469. Use XrmGetDataBase to retrieve a database from nonvolatile
  23470. storage. The definition for this function is:
  23471.  
  23472. XrmResourceDataBase XrmGetDataBase(db_filename)
  23473.       char *db_filename;
  23474.  
  23475.  
  23476. db_filenameSpecifies the resource database file name.
  23477.  
  23478. The XrmGetDataBase function is used primarily to get a copy
  23479. of the global user-preference database.  However, it also
  23480. can be used to retrieve stored copies of other resource
  23481. databases (perhaps, those from earlier invocations of the
  23482. program or a database editor).
  23483.  
  23484.  
  23485. Use XrmPutDataBase to store a copy of the application's
  23486. current database in nonvolatile storage. The definition for
  23487. this function is:
  23488.  
  23489. void XrmPutDataBase(db_filename, db)
  23490.       char *db_filename;
  23491.       XrmResourceDataBase db;
  23492.  
  23493.  
  23494. db_filenameSpecifies the resource database file name.
  23495.  
  23496. db        Specifies the descriptor of the resource database.
  23497.  
  23498. The XrmPutDataBase function stores a copy of the
  23499. application's current database into a file.
  23500.  
  23501.  
  23502. Use XrmLoadDataBase to retrieve a resource from the database
  23503. and add it to a string.  The definition for this function
  23504. is:
  23505.  
  23506. XrmResourceDataBase XrmLoadDataBase(data)
  23507.      char *data;
  23508.  
  23509.  
  23510.  
  23511.  
  23512.  
  23513.                      December 18, 1987
  23514.  
  23515.  
  23516.  
  23517.  
  23518.  
  23519.                           - 345 -
  23520.  
  23521.  
  23522. data      Specifies the data string.
  23523.  
  23524. The XrmLoadDataBase adds the resources in the specified
  23525. null-terminated string.  XrmLoadDataBase is similar to
  23526. XrmGetDataBase, except that it reads the information out of
  23527. a string instead of a file.
  23528.  
  23529. 10.11.6.  Parsing Command Line Options
  23530.  
  23531. Use XrmParseCommand to load a resource data base from a C
  23532. command line.  The definition for this function is:
  23533.  
  23534.  
  23535.         typedef enum {
  23536.             XrmoptionNoArg,           /* Value is specified in OptionDescRec.value    */
  23537.             XrmoptionIsArg,           /* Value is the option string itself    */
  23538.             XrmoptionStickyArg,       /* Value is characters immediately following option */
  23539.             XrmoptionSepArg,          /* Value is next argument in argv    */
  23540.             XrmoptionSkipArg,         /* Ignore this option and the next argument in argv */
  23541.             XrmoptionSkipLine         /* Ignore this option and the rest of argv    */
  23542.         } XrmOptionKind;
  23543.  
  23544.         typedef struct {
  23545.             char *option;             /* Option abbreviation in argv    */
  23546.             char *resourceName;       /* Resource name (sans application name)    */
  23547.             XrmOptionKind argKind;/* Which style of option it is    */
  23548.             caddr_t value;            /* Value to provide if XrmoptionNoArg    */
  23549.         } XrmOptionDescRec, *XrmOptionDescList;
  23550.  
  23551.  
  23552.  
  23553. void XrmParseCommand(db, table, table_count, name, argc_return, argv_return,)
  23554.       XrmResourceDataBase *db;
  23555.       XrmOptionDescList table;
  23556.       int table_count;
  23557.       char *name;
  23558.       int *argc_return;
  23559.       char **argv_return;
  23560.  
  23561.  
  23562. db        Specifies the descriptor of the resource database.
  23563.  
  23564. table     Specifies table of command line arguments to be
  23565.           parsed.
  23566.  
  23567. count     Specifies the number of entries in the table.
  23568.  
  23569. name      Specifies the application name.
  23570.  
  23571. argc_returnBefore the call, contains the number of argu-
  23572.           ments, after the call, returns the number of
  23573.           remaining arguments.
  23574.  
  23575.  
  23576.  
  23577.  
  23578.  
  23579.                      December 18, 1987
  23580.  
  23581.  
  23582.  
  23583.  
  23584.  
  23585.                           - 346 -
  23586.  
  23587.  
  23588. argv_returnBefore the call, a pointer to the command line
  23589.           arguments.  After the call, matched arguments have
  23590.           been removed.
  23591.  
  23592. The XrmParseCommand function parses an (arc, argv) pair in
  23593. your main program according to the specified option table,
  23594. loads recognised options into the specified database, and
  23595. modifies the (arc, argv) pair to remove all recognised
  23596. options.
  23597.  
  23598.  
  23599. The specified table is used to parse the command line.
  23600. Recognised entries in the table are removed from argv, and
  23601. entries are made in the specified resource data base.  The
  23602. table entries contain information on the option string, the
  23603. the option name, which style of option and a value to pro-
  23604. vide if the option kind is XrmoptionNoArg.  The argc argu-
  23605. ment specifies the number of arguments in argv, and is set
  23606. to the remaining number of arguments that were not parsed.
  23607. The name argument should be the name of your application for
  23608. use in building the data base entry.
  23609.  
  23610. 10.12.  Using the Context Manager
  23611.  
  23612. The context manager provides a way of associating data with
  23613. a window in your program. Any amount of data in any number
  23614. of pieces can be associated with a window, and each piece of
  23615. data has a type associated with it. The context manager
  23616. requires knowledge of the window ID and type to store or
  23617. retrieve data.
  23618.  
  23619. Essentially, the context manager can be viewed as a two-
  23620. dimensional, sparse array:  one dimension is subscripted by
  23621. the window ID and the other by a context type field.  Each
  23622. entry in the array contains a pointer to the data.  Xlib
  23623. provides context management functions with which you can
  23624. save data values, get data values, delete entries, and
  23625. create a unique context type.  The symbols used are in
  23626. <X11/Xutil.h> header file.
  23627.  
  23628.  
  23629. Use XSaveContext to save a data value that corresponds to a
  23630. window and context type. The definition for this function
  23631. is:
  23632.  
  23633. int XSaveContext(display, w, context, data)
  23634.       Display *display;
  23635.       Window w;
  23636.       XContext context;
  23637.       caddr_t data;
  23638.  
  23639.  
  23640.  
  23641.  
  23642.  
  23643.  
  23644.  
  23645.                      December 18, 1987
  23646.  
  23647.  
  23648.  
  23649.  
  23650.  
  23651.                           - 347 -
  23652.  
  23653.  
  23654. display   Specifies the connection to the X server.
  23655.  
  23656. w         Specifies the window with which the data is asso-
  23657.           ciated.
  23658.  
  23659. context   Specifies the context type to which the data
  23660.           belongs.
  23661.  
  23662. data      Specifies the data to be associated with the win-
  23663.           dow and type.
  23664.  
  23665. If an entry with the specified window and type already
  23666. exists, XSaveContext overrides it with the specified con-
  23667. text. However, this override has costs in time and space. If
  23668. you know the entry already exists, it is better to call
  23669. XDeleteContext first.  The XSaveContext function returns
  23670. nonzero error code if an error has occurred and zero (0)
  23671. otherwise.  Possible errors are XCNOMEM (out of memory).
  23672.  
  23673.  
  23674. Use XFindContext to get the data associated with a window
  23675. and type. The definition for this function is:
  23676.  
  23677. int XFindContext(display, w, context, data_return)
  23678.       Display *display;
  23679.       Window w;
  23680.       XContext context;
  23681.       caddr_t *data_return;
  23682.  
  23683.  
  23684. display   Specifies the connection to the X server.
  23685.  
  23686. w         Specifies the window with which the data is asso-
  23687.           ciated.
  23688.  
  23689. context   Specifies the context type to which the data
  23690.           belongs.
  23691.  
  23692. data_returnReturns a pointer to the data.
  23693.  
  23694. Because it is a return value, the data is a pointer.  The
  23695. XFindContext function returns nonzero error code if an error
  23696. has occurred and zero (0) otherwise. Possible errors are
  23697. XCNOENT (context-not-found).
  23698.  
  23699.  
  23700. Use XDeleteContext to delete an entry for a given window and
  23701. type. The definition for this function is:
  23702.  
  23703. int XDeleteContext(display, w, context)
  23704.       Display *display;
  23705.       Window w;
  23706.       XContext context;
  23707.  
  23708.  
  23709.  
  23710.  
  23711.                      December 18, 1987
  23712.  
  23713.  
  23714.  
  23715.  
  23716.  
  23717.                           - 348 -
  23718.  
  23719.  
  23720. display   Specifies the connection to the X server.
  23721.  
  23722. w         Specifies the window with which the data is asso-
  23723.           ciated.
  23724.  
  23725. context   Specifies the context type to which the data
  23726.           belongs.
  23727.  
  23728. The XDeleteContext function deletes the entry for the given
  23729. window and type from the data structure.  This returns the
  23730. same error codes that XFindContext returns if called with
  23731. the same arguments.
  23732.  
  23733.  
  23734. Use XUniqueContext to create a unique context type that may
  23735. be used in subsequent calls to XSaveContext.  and XFindCon-
  23736. text.  The definition for this function is:
  23737.  
  23738. XContext XUniqueContext()
  23739.  
  23740.  
  23741.  
  23742.  
  23743.  
  23744.  
  23745.  
  23746.  
  23747.  
  23748.  
  23749.  
  23750.  
  23751.  
  23752.  
  23753.  
  23754.  
  23755.  
  23756.  
  23757.  
  23758.  
  23759.  
  23760.  
  23761.  
  23762.  
  23763.  
  23764.  
  23765.  
  23766.  
  23767.  
  23768.  
  23769.  
  23770.  
  23771.  
  23772.  
  23773.  
  23774.  
  23775.  
  23776.  
  23777.                      December 18, 1987
  23778.  
  23779.  
  23780.  
  23781.  
  23782.  
  23783.                           - 349 -
  23784.  
  23785.  
  23786.  
  23787.  
  23788.                          Appendix A
  23789.  
  23790.                     Protocol Extensions
  23791.  
  23792.  
  23793.  
  23794. Appendix A - Protocol Extensions Because X can only evolve
  23795. by extension to the core protocol, it is important that
  23796. extensions not be perceivable as second class citizens.  At
  23797. some point, your favorite extensions may be adopted as addi-
  23798. tional parts of the ``X Standard''.
  23799.  
  23800. Therefore, there should be little to distinguish the use of
  23801. an extension from that of the core protocol.  To avoid hav-
  23802. ing to initialize extensions explicitly in application pro-
  23803. grams, it is also important that extensions perform ``lazy
  23804. evaluations'' and automatically initialize themselves when
  23805. called for the first time.
  23806.  
  23807. This appendix describes techniques for writing extensions to
  23808. Xlib that will run at essentially the same performance as
  23809. the core protocol requests.
  23810.  
  23811.                             Note
  23812.  
  23813.      It is expected that a given extension to X con-
  23814.      sists of multiple requests.  Defining 10 new
  23815.      features as 10 separate extensions is very bad
  23816.      practice.  Rather, they should be packaged into a
  23817.      single extension and should use minor opcodes to
  23818.      distinguish the features.
  23819.  
  23820.  
  23821. Basic Protocol Support Routines
  23822.  
  23823. The basic protocol requests for extensions are XQueryExten-
  23824. sion, XListExtensions.
  23825.  
  23826. Bool XQueryExtension(display, name, major_opcode, first_event, first_error)
  23827.       Display *display;
  23828.       char *name;
  23829.       int *major_opcode;      /* RETURN */
  23830.       int *first_event;       /* RETURN */
  23831.       int *first_error;       /* RETURN */
  23832.  
  23833. XQueryExtension determines if the named extension is
  23834. present. If so, the major opcode for the extension is
  23835. returned (if it has one).  Otherwise, zero is returned. Any
  23836. minor opcode and the request formats are specific to the
  23837. extension. If the extension involves additional event types,
  23838. the base event type code is returned.  Otherwise, zero is
  23839. returned. The format of the events is specific to the
  23840.  
  23841.  
  23842.  
  23843.                      December 18, 1987
  23844.  
  23845.  
  23846.  
  23847.  
  23848.  
  23849.                           - 350 -
  23850.  
  23851.  
  23852. extension. If the extension involves additional error codes,
  23853. the base error code is returned. Otherwise, zero is
  23854. returned. The format of additional data in the errors is
  23855. specific to the extension.
  23856.  
  23857. The extension name should be in the ISO LATIN-1 encoding,
  23858. and upper/lower case does matter.
  23859.  
  23860. char **XListExtensions(display, nextensions)
  23861.       Display *display;
  23862.       int *nextensions;
  23863.  
  23864. XListExtensions returns a list of all extensions supported
  23865. by the server.
  23866.  
  23867. XFreeExtensionList(list)
  23868.       char **list;
  23869.  
  23870. XFreeExtensionList frees the memory allocated by XListExten-
  23871. sions.
  23872.  
  23873. Hooking into Xlib
  23874.  
  23875. These functions allow one to hook into the library. They are
  23876. not normally used by application programmers but are used by
  23877. people who need to extend the core X protocol and the X
  23878. library interface.  The functions, which generate protocol
  23879. requests for X, are typically called ``stubs''.
  23880.  
  23881. In extensions, stubs first should check to see if they have
  23882. initialized themselves on a connection.  If they have not,
  23883. they then should call XInitExtension to attempt to initial-
  23884. ize themselves on the connection.
  23885.  
  23886. If the extension needs to be informed of GC/font allocation
  23887. or deallocation, or if the extension defines new event
  23888. types, the functions described in the following sections
  23889. allow an extension to be called when these events occur.
  23890.  
  23891. In <X11/Xlib.h>, the following structure is defined to
  23892. return the information from XQueryExtension.
  23893.  
  23894. typedef struct _XExtCodes {   /* public to extension, cannot be changed */
  23895.      int extension;           /* extension number */
  23896.      int major_opcode;        /* major op-code assigned by server */
  23897.      int first_event;         /* first event number for the extension */
  23898.      int first_error;         /* first error number for the extension */
  23899. } XExtCodes;
  23900.  
  23901.  
  23902.  
  23903. XExtCodes *XInitExtension(display, name)
  23904.       Display *display;
  23905.       char *name;
  23906.  
  23907.  
  23908.  
  23909.                      December 18, 1987
  23910.  
  23911.  
  23912.  
  23913.  
  23914.  
  23915.                           - 351 -
  23916.  
  23917.  
  23918. XInitExtension first calls XQueryExtension to see if the
  23919. extension exists. Then, it allocates storage for maintaining
  23920. the information about the extension on the connection,
  23921. chains this onto the extension list for the connection, and
  23922. returns the information the stub implementor will need to
  23923. access the extension.
  23924.  
  23925. In particular, the extension number in the XExtCodes struc-
  23926. ture is needed in other calls below. This extension number
  23927. is unique only to a single connection.
  23928.  
  23929. Hooks into the Library
  23930.  
  23931. These functions allow you to define procedures which are to
  23932. be called when various circumstances occur.  The procedures
  23933. include the creation of a new GC for a connection, the copy-
  23934. ing of a GC, the freeing a GC, the creating and freeing of
  23935. fonts, the conversion of events defined by extensions to and
  23936. from wire format, and the handling of errors.
  23937.  
  23938. All of these functions return the previous routine defined
  23939. for this extension.
  23940.  
  23941. int (*XESetCloseDisplay(display, extension, proc))()
  23942.       Display *display;       /* display */
  23943.       int extension;          /* extension number */
  23944.       int (*proc)();          /* routine to call when display closed */
  23945.  
  23946. You use this procedure to define a procedure to be called
  23947. whenever XCloseDisplay is called. This procedure returns any
  23948. previously defined procedure, usually NULL.
  23949.  
  23950. When XCloseDisplay is called, your routine is called with
  23951. these arguments:
  23952.  
  23953. (*proc)(display, codes)
  23954.      Display *display;
  23955.      XExtCodes *codes;
  23956.  
  23957.  
  23958.  
  23959. int (*XESetCreateGC(display, extension, proc))()
  23960.       Display *display;       /* display */
  23961.       int extension;          /* extension number */
  23962.       int (*proc)();          /* routine to call when GC created */
  23963.  
  23964. You use this procedure to define a procedure to be called
  23965. whenever a new GC is created. This procedure returns any
  23966. previously defined procedure, usually NULL.
  23967.  
  23968. When a GC is created, your routine will be called with these
  23969. arguments:
  23970.  
  23971.  
  23972.  
  23973.  
  23974.  
  23975.                      December 18, 1987
  23976.  
  23977.  
  23978.  
  23979.  
  23980.  
  23981.                           - 352 -
  23982.  
  23983.  
  23984. (*proc)(display, gc, codes)
  23985.      Display *display;
  23986.      GC gc;
  23987.      XExtCodes *codes;
  23988.  
  23989.  
  23990.  
  23991. int (*XESetCopyGC(display, extension, proc))()
  23992.       Display *display;       /* display */
  23993.       int extension;          /* extension number */
  23994.       int (*proc)();          /* routine to call when GC copied */
  23995.  
  23996. You use this procedure to define a procedure to be called
  23997. whenever a GC is copied. This procedure returns any previ-
  23998. ously defined procedure, usually NULL.
  23999.  
  24000. When a GC is copied, your routine will be called with these
  24001. arguments:
  24002.  
  24003. (*proc)(display, gc, codes)
  24004.      Display *display;
  24005.      GC gc;
  24006.      XExtCodes *codes;
  24007.  
  24008.  
  24009.  
  24010. int (*XESetFreeGC(display, extension, proc))()
  24011.       Display *display;       /* display */
  24012.       int extension;          /* extension number */
  24013.       int (*proc)();          /* routine to call when GC freed */
  24014.  
  24015. You use this procedure to define a procedure to be called
  24016. whenever a GC is freed. This procedure returns any previ-
  24017. ously defined procedure, usually NULL.
  24018.  
  24019. When a GC is freed, your routine will be called with these
  24020. arguments:
  24021.  
  24022. (*proc)(display, gc, codes)
  24023.      Display *display;
  24024.      GC gc;
  24025.      XExtCodes *codes;
  24026.  
  24027.  
  24028.  
  24029. int (*XESetCreateFont(display, extension, proc))()
  24030.       Display *display;       /* display */
  24031.       int extension;          /* extension number */
  24032.       int (*proc)();          /* routine to call when font created */
  24033.  
  24034. You use this procedure to define a procedure to be called
  24035. whenever XLoadQueryFont is called. This procedure returns
  24036. any previously defined procedure, usually NULL.
  24037.  
  24038.  
  24039.  
  24040.  
  24041.                      December 18, 1987
  24042.  
  24043.  
  24044.  
  24045.  
  24046.  
  24047.                           - 353 -
  24048.  
  24049.  
  24050. When XLoadQueryFont is called, your routine will be called
  24051. with these arguments:
  24052.  
  24053. (*proc)(display, fs, codes)
  24054.      Display *display;
  24055.      XFontStruct *fs;
  24056.      XExtCodes *codes;
  24057.  
  24058.  
  24059.  
  24060. int (*XESetFreeFont(display, extension, proc))()
  24061.       Display *display;       /* display */
  24062.       int extension;          /* extension number */
  24063.       int (*proc)();          /* routine to call when font freed */
  24064.  
  24065. You use this procedure to define a procedure to be called
  24066. whenever XFreeFont is called. This procedure returns any
  24067. previously defined procedure, usually NULL.
  24068.  
  24069. When XFreeFont is called, your routine will be called with
  24070. these arguments:
  24071.  
  24072. (*proc)(display, fs, codes)
  24073.      Display *display;
  24074.      XFontStruct *fs;
  24075.      XExtCodes *codes;
  24076.  
  24077. The next two functions allow you to define new events to the
  24078. library.
  24079.  
  24080.                             Note
  24081.  
  24082.      There is an implementation limit such that your
  24083.      host event structure size cannot be bigger than
  24084.      the size of the XEvent union of structures.
  24085.  
  24086.  
  24087. int (*XESetWireToEvent(display, event_number, proc))()
  24088.       Display *display;       /* display */
  24089.       int event_number;       /* event routine to replace */
  24090.       int (*proc)();          /* routine to call when converting event */
  24091.  
  24092. You use this procedure to define a procedure to be called
  24093. when an event needs to be converted from wire format (
  24094. xEvent) to host format ( XEvent) form. The event number
  24095. defines which protocol event number to install a conversion
  24096. routine for.  This procedure returns any previously defined
  24097. procedure.
  24098.  
  24099.                             Note
  24100.  
  24101.      You can replace a core event conversion routine
  24102.      with one of your own, though this is not
  24103.      encouraged.  It would, however, allow you to
  24104.  
  24105.  
  24106.  
  24107.                      December 18, 1987
  24108.  
  24109.  
  24110.  
  24111.  
  24112.  
  24113.                           - 354 -
  24114.  
  24115.  
  24116.      intercept a core event and modify it before being
  24117.      enqueued or otherwise examined.
  24118.  
  24119. When Xlib needs to convert an event from wire format to
  24120. natural host format, your routine will be called with these
  24121. arguments:
  24122.  
  24123. (*proc)(display, re, event)
  24124.      Display *display;
  24125.      XEvent *re;
  24126.      xEvent event;
  24127.  
  24128. The re argument is a pointer to where the host format event
  24129. should be stored, while the event argument is the 32-byte
  24130. wire event structure.  In the XEvent structure you are
  24131. creating, type must be the first member and window must be
  24132. the second member.  You should fill in the type member with
  24133. the type specified for the xEvent structure.  You should
  24134. copy all other members from the xEvent structure (wire for-
  24135. mat) to the XEvent structure (host format).
  24136.  
  24137. int (*XESetEventToWire(display, event_number, proc))()
  24138.       Display *display;       /* display */
  24139.       int event_number;       /* event routine to replace */
  24140.       (*proc)();              /* routine to call when converting event */
  24141.  
  24142. You use this procedure to define a procedure to be called
  24143. when an event needs to be converted from host format (
  24144. XEvent) to wire format ( xEvent) form. The event number
  24145. defines which protocol event number to install a conversion
  24146. routine for.  This procedure returns any previously defined
  24147. procedure.
  24148.  
  24149.                             Note
  24150.  
  24151.      You can replace a core event conversion routine
  24152.      with one of your own, though this is not
  24153.      encouraged. It would, however, allow you to inter-
  24154.      cept a core event and modify it before being sent
  24155.      to another client.
  24156.  
  24157. When Xlib needs to convert an event from wire format to
  24158. natural host format, your routine will be called with these
  24159. arguments:
  24160.  
  24161. (*proc)(display, re, event)
  24162.      Display *display;
  24163.      XEvent *re;
  24164.      xEvent event;
  24165.  
  24166. The re argument is a pointer to the host format event, while
  24167. the event argument is a pointer to where the 32-byte wire
  24168. event structure should be stored.  In the XEvent structure
  24169. that you are forming, you must have ``type'' the first
  24170.  
  24171.  
  24172.  
  24173.                      December 18, 1987
  24174.  
  24175.  
  24176.  
  24177.  
  24178.  
  24179.                           - 355 -
  24180.  
  24181.  
  24182. element and ``window'' the second.  You then should fill in
  24183. the type with the type from the xEvent structure.  All other
  24184. elements then should be copied from the wire format to the
  24185. XEvent structure.
  24186.  
  24187. int (*XESetError(display, extension, proc))()
  24188.       Display *display;       /* display */
  24189.       int extension;          /* extension number */
  24190.       int (*proc)();          /* routine to call when X error happens */
  24191.  
  24192. Inside Xlib, there are times that you may want to suppress
  24193. the calling of the external error handling when an error
  24194. occurs.  This allows status to be returned on a call at the
  24195. cost of the call being synchronous (though most such rou-
  24196. tines are query operations, in any case, and are typically
  24197. programmed to be synchronous).
  24198.  
  24199. When Xlib detects an protocol error in _XReply, it will call
  24200. your procedure with these arguments:
  24201.  
  24202. int (*proc)(display, err, codes, ret_code)
  24203.      Display *display;
  24204.      xError *err;
  24205.      XExtCodes *codes;
  24206.      int *ret_code;
  24207.  
  24208. The err argument is a pointer to the 32 byte wire format
  24209. error.  The codes argument is a pointer to the extension
  24210. codes structure.  The ret_code argument is the return code
  24211. you may want _XReply to return.
  24212.  
  24213. If your routine returns a value 0, the error is not
  24214. suppressed, and XError is called.  If your routine returns
  24215. nonzero, the error is suppressed, and _XReply returns the
  24216. value of ret_code.
  24217.  
  24218. char  *(*XESetErrorString(display, extension, proc))()
  24219.       Display *display;       /* display */
  24220.       int extension;          /* extension number */
  24221.       char *(*proc)();        /* routine to call when I/O error happens */
  24222.  
  24223.  
  24224. int (*XESetFlushGC(display, extension, proc))()
  24225.       Display *display;       /* display */
  24226.       int extension;          /* extension number */
  24227.       char *(*proc)();        /* routine to call when I/O error happens */
  24228.  
  24229. The XESetFlushGC procedure is identical to XSetCopyGC,
  24230. except that XESetFlushGC is called when a GC is cache need
  24231. to be updated in the server.
  24232.  
  24233. The XGetErrorText function returns a string to the user for
  24234. an error. This procedure allows you to define a routine to
  24235. be called which should return a pointer to the error
  24236.  
  24237.  
  24238.  
  24239.                      December 18, 1987
  24240.  
  24241.  
  24242.  
  24243.  
  24244.  
  24245.                           - 356 -
  24246.  
  24247.  
  24248. message.  The following is an example.
  24249.  
  24250. char *(*proc)(display, code, codes)
  24251.      Display *display;
  24252.      int code;
  24253.      XExtCodes *codes;
  24254.  
  24255. Your procedure is called with the error code detected.  You
  24256. should return a pointer to a null terminated string contain-
  24257. ing the error message.
  24258.  
  24259. Hooks onto Xlib Data Structures
  24260.  
  24261. Various Xlib data structures have provisions for extension
  24262. routines to chain extension supplied data onto a list.
  24263. These structures are:  GC, Visual, Screen, ScreenFormat,
  24264. Display, and XFontStruct.  Because the list pointer is
  24265. always the first element in the structure, a single set of
  24266. routines can be used to manipulate the data on these lists.
  24267.  
  24268. The following structure is used in the routines in this sec-
  24269. tion and is defined in <X11/Xlib.h>.
  24270.  
  24271. typedef struct _XExtData {
  24272.      int number;              /* number returned by XInitExtension */
  24273.      struct _XExtData *next;  /* next item on list of data for structure */
  24274.      int (*free)();           /* if defined,  called to free private */
  24275.      char *private;           /* data private to this extension. */
  24276. } XExtData;
  24277.  
  24278. When any of the data structures listed above are freed, the
  24279. list is walked, and the free routine (if any) is called. If
  24280. free is NULL, then the library will free the data pointed to
  24281. by private and the structure, itself.
  24282.  
  24283. XAddToExtensionList(structure, ext_data)
  24284.       struct _XExtData **structure;/* pointer to structure to add */
  24285.       XExtData *ext_data;     /* extension data structure to add */
  24286.  
  24287. The structure argument is a pointer to one of the data
  24288. structures enumerated above.  You must initialize ext_data-
  24289. >number with the extension number before calling this rou-
  24290. tine.
  24291.  
  24292. It is expected that an extension will add at most one exten-
  24293. sion data structure to any single data structure's extension
  24294. data list.
  24295.  
  24296. XExtData *XFindOnExtensionList(structure, number)
  24297.       struct _XExtData **structure;
  24298.       int number;             /* extension number from XInitExtension*/
  24299.  
  24300. XFindOnExtensionList returns the first extension data struc-
  24301. ture for the extension numbered number.
  24302.  
  24303.  
  24304.  
  24305.                      December 18, 1987
  24306.  
  24307.  
  24308.  
  24309.  
  24310.  
  24311.                           - 357 -
  24312.  
  24313.  
  24314. The XAllocID macro, which allocates and returns a resource
  24315. ID, is defined in <X11/Xlib.h>.
  24316.  
  24317. XAllocIDdisplay)
  24318.      Display *display;
  24319.  
  24320. This macro is a call through the Display structure to the
  24321. internal resource ID allocator.  It returns a resource ID
  24322. that you can use when creating new resources.
  24323.  
  24324. GC Caching
  24325.  
  24326. GCs are cached by the library, to allow merging of indepen-
  24327. dent change requests to the same GC into single protocol
  24328. requests.  This is typically called a "write back" cache.
  24329. Any extension routine whose behavior depends on the contents
  24330. of a GC must flush the GC cache, to make sure the server has
  24331. up to date contents in its GC.
  24332.  
  24333. The FlushGC macro checks the dirty bits in the library's GC
  24334. structure and calls _XFlushGCCache if any elements have
  24335. changed.  The FlushGC macros is defined as follows:
  24336.  
  24337. FlushGC (display, gc)
  24338.       Display *display;
  24339.       GC gc;
  24340.  
  24341.  
  24342. Note that if you extend the GC to add additional resource ID
  24343. components, you should ensure that the library stub immedi-
  24344. ately sends the change request.  This is because a client
  24345. can free a resource immediately after using it, so if you
  24346. only stored the value in the cache without forcing a proto-
  24347. col request, the resource might be destroyed before being
  24348. set into the GC.  You can use the _XFlushGCCache procedure
  24349. to force the cache to be flushed.  The _XFlushGCCache pro-
  24350. cedure is defined as follows:
  24351.  
  24352. _XFlushGCCache (display, gc)
  24353.       Display *display;
  24354.       GC gc;
  24355.  
  24356.  
  24357. Graphics Batching
  24358.  
  24359. If you extend X to add more poly graphics primitives, you
  24360. may be able to take advantage of facilities in the library
  24361. to allow back-to-back single calls to be transformed into
  24362. poly requests.  This may dramatically improve performance of
  24363. programs that are not written using poly requests. In the
  24364. display structure is a pointer to an xReq called last_req
  24365. which is the last request being processed. By checking that
  24366. the last request type, drawable, gc, and other options are
  24367. the same as the new one, and that there is enough space left
  24368.  
  24369.  
  24370.  
  24371.                      December 18, 1987
  24372.  
  24373.  
  24374.  
  24375.  
  24376.  
  24377.                           - 358 -
  24378.  
  24379.  
  24380. in the buffer, you may be able to just extend the previous
  24381. graphics request by extending the length field of the
  24382. request and appending the data to the buffer. This can cause
  24383. a 5 times or more improvement in stupid programs. For exam-
  24384. ple, here is the source for the XDrawPoint stub.  (Writing
  24385. extension stubs is discussed in the next section.)
  24386.  
  24387.      #include "copyright.h"
  24388.  
  24389.      #include "Xlibint.h"
  24390.  
  24391.      /* precompute the maximum size of batching request allowed */
  24392.  
  24393.      static int size = sizeof(xPolyPointReq) + EPERBATCH * sizeof(xPoint);
  24394.  
  24395.      XDrawPoint(dpy, d, gc, x, y)
  24396.          register Display *dpy;
  24397.          Drawable d;
  24398.          GC gc;
  24399.          int x, y; /* INT16 */
  24400.      {
  24401.          xPoint *point;
  24402.          LockDisplay(dpy);
  24403.          FlushGC(dpy, gc);
  24404.          {
  24405.          register xPolyPointReq *req = (xPolyPointReq *) dpy->last_req;
  24406.          /* if same as previous request, with same drawable, batch requests */
  24407.          if (
  24408.                (req->reqType == X_PolyPoint)
  24409.             && (req->drawable == d)
  24410.             && (req->gc == gc->gid)
  24411.             && (req->coordMode == CoordModeOrigin)
  24412.             && ((dpy->bufptr + sizeof (xPoint)) <= dpy->bufmax)
  24413.             && (((char *)dpy->bufptr - (char *)req) < size) ) {
  24414.               point = (xPoint *) dpy->bufptr;
  24415.               req->length += sizeof (xPoint) >> 2;
  24416.               dpy->bufptr += sizeof (xPoint);
  24417.               }
  24418.  
  24419.          else {
  24420.              GetReqExtra(PolyPoint, 4, req); /* 1 point = 4 bytes */
  24421.              req->drawable = d;
  24422.              req->gc = gc->gid;
  24423.              req->coordMode = CoordModeOrigin;
  24424.              point = (xPoint *) (req + 1);
  24425.              }
  24426.          point->x = x;
  24427.          point->y = y;
  24428.          }
  24429.          UnlockDisplay(dpy);
  24430.          SyncHandle();
  24431.      }
  24432.  
  24433. There is a limit of EPERBATCH on the number of requests
  24434.  
  24435.  
  24436.  
  24437.                      December 18, 1987
  24438.  
  24439.  
  24440.  
  24441.  
  24442.  
  24443.                           - 359 -
  24444.  
  24445.  
  24446. batched, to keep clients from generating very long requests
  24447. that may monopolize the server.  Most of the performance
  24448. benefit occurs in the first few merged requests.  Note that
  24449. FlushGC is called BEFORE picking up the value of last_req,
  24450. since it may modify this field.
  24451.  
  24452. Writing Extension Stubs
  24453.  
  24454. All X requests always contain the length of the request,
  24455. expressed as a 16-bit quantity of 32-bits.  This means that
  24456. a single request can be no more than 256k Bytes in length.
  24457. Some servers may not support single requests of such a
  24458. length.  The value of dpy->max_request_size contains the
  24459. maximum length as defined by the server implementation.  For
  24460. further information, see the X Protocol documentation.
  24461.  
  24462. Requests, Replies, and Xproto.h
  24463.  
  24464. It may make it easier to understand if you look at the
  24465. Xproto.h header file. The file contains three sets of defin-
  24466. itions that are of interest to the stub implementor: request
  24467. names, request structures, and reply structures.
  24468.  
  24469. You need to generate a file equivalent to Xproto.h for your
  24470. extension and need to include it in your stub routine.  Each
  24471. stub routine also must include Xlibint.h.
  24472.  
  24473. The identifiers are deliberately chosen in such a way that,
  24474. if the request is called X_DoSomething, then its request
  24475. structure is xDoSomethingReq, and its reply is xDo-
  24476. SomethingReply. The ``GetReq'' family of macros, defined in
  24477. Xlibint.h, takes advantage of this naming scheme.
  24478.  
  24479. For each X Request, there is a definition in Xproto.h that
  24480. looks similar to this:
  24481.  
  24482.  
  24483.         #define X_DoSomething   42
  24484.  
  24485. In your extension header file, this will be a minor op-code,
  24486. instead of a major opcode.
  24487.  
  24488. Request Format
  24489.  
  24490. Every request contains an 8-bit ``major'' opcode and a 16-
  24491. bit length field expressed in units of 4 bytes. Every
  24492. request consists of 4 bytes of header (containing the major
  24493. opcode, the length field, and a data byte) followed by zero
  24494. or more additional bytes of data. The length field defines
  24495. the total length of the request, including the header. The
  24496. length field in a request must equal the minimum length
  24497. required to contain the request. If the specified length is
  24498. smaller or larger than the required length, the extension
  24499. should generate a BadLength error.  Unused bytes in a
  24500.  
  24501.  
  24502.  
  24503.                      December 18, 1987
  24504.  
  24505.  
  24506.  
  24507.  
  24508.  
  24509.                           - 360 -
  24510.  
  24511.  
  24512. request are not required to be zero.
  24513.  
  24514. Major opcodes 128 through 255 are reserved for extensions.
  24515. Extensions are intended to contain multiple requests, so
  24516. extension requests typically have an additional minor opcode
  24517. encoded in the ``spare'' data byte in the request header,
  24518. but the placement and interpretation of this minor opcode as
  24519. well as all other fields in extension requests are not
  24520. defined by the core protocol.  Every request is implicitly
  24521. assigned a sequence number (starting with one) used in
  24522. replies, errors, and events.
  24523.  
  24524. Most protocol requests have a corresponding structure
  24525. typedef in Xproto.h, which looks like:
  24526.  
  24527. typedef struct _DoSomethingReq {
  24528.      CARD8 reqType;           /* X_DoSomething */
  24529.      CARD8 someDatum;         /* used differently in different requests */
  24530.      CARD16 length;           /* total # of bytes in request, divided by 4 */
  24531.      ...
  24532.      /* request-specific data */
  24533.      ...
  24534. } xDoSomethingReq;
  24535.  
  24536. If a core protocol request has a single 32-bit argument, you
  24537. need not declare a request structure in your extension
  24538. header file.  Instead, such requests use Xproto.h's xResour-
  24539. ceReq structure. This structure is used for any request
  24540. whose single argument is a Window, Pixmap, Drawable, GCon-
  24541. text, Font, Cursor, Colormap, Device, Atom, VisualID, or
  24542. Time.
  24543.  
  24544. typedef struct _ResourceReq {
  24545.      CARD8 reqType;           /* the request type, e.g. X_DoSomething */
  24546.      BYTE pad;                /* not used */
  24547.      CARD16 length;           /* 2 (= total # of bytes in request, divided by 4) */
  24548.      CARD32 id;               /* the Window, Drawable, Font, GContext, etc. */
  24549. } xResourceReq;
  24550.  
  24551. If convenient, you can do something similar in your exten-
  24552. sion header file.
  24553.  
  24554. In both of these structures, the reqType field identifies
  24555. the type of the request (for example, X_MapWindow or
  24556. X_CreatePixmap). The length field tells how long, in units
  24557. of 4-byte ``longwords'', the request is. This length
  24558. includes both the request structure itself and any variable
  24559. length data, such as strings or lists, that follow the
  24560. request structure. Request structures come in different
  24561. sizes, but all requests are padded to be a multiple of 4
  24562. bytes long.
  24563.  
  24564. A few protocol requests take no arguments at all. Instead,
  24565. they use Xproto.h's xReq structure, which contains only a
  24566.  
  24567.  
  24568.  
  24569.                      December 18, 1987
  24570.  
  24571.  
  24572.  
  24573.  
  24574.  
  24575.                           - 361 -
  24576.  
  24577.  
  24578. reqType and a length (and a pad byte).
  24579.  
  24580. If the protocol request requires a reply, then Xproto.h also
  24581. contains a reply structure typedef:
  24582.  
  24583. typedef struct _DoSomethingReply {
  24584.      BYTE type;               /* always X_Reply */
  24585.      BYTE someDatum;          /* used differently in different requests */
  24586.      CARD16 sequenceNumber;   /* # of requests sent so far */
  24587.      CARD32 length;           /* # of additional bytes, divided by 4 */
  24588.      ...
  24589.      /* request-specific data */
  24590.      ...
  24591. } xDoSomethingReply;
  24592.  
  24593. Most of these reply structures are 32 bytes long. If there
  24594. are not that many reply values, then they contain a suffi-
  24595. cient number of pad fields to bring them up to 32 bytes. The
  24596. length field is the total number of bytes in the request
  24597. minus 32, divided by 4. This length will be nonzero only if:
  24598.  
  24599. o    The reply structure is followed by variable length data
  24600.      such as a list or string
  24601.  
  24602. o    The reply structure is longer than 32 bytes
  24603.  
  24604. Only GetWindowAttributes, QueryFont, QueryKeymap, and Get-
  24605. KeyboardControl have reply structures longer than 32 bytes.
  24606.  
  24607. A few protocol requests return replies that contain no data.
  24608. Xproto.h does not define reply structures for these.
  24609. Instead, they use the xGenericReply structure, which con-
  24610. tains only a type, length, and sequence number (and suffi-
  24611. cient padding to make it 32 bytes long).
  24612.  
  24613. Starting to Write a Stub Routine
  24614.  
  24615. An Xlib stub routine should always start like this:
  24616.  
  24617.  
  24618.         #include "Xlibint.h"
  24619.  
  24620.         XDoSomething (arguments, ... )
  24621.         /* argument declarations */
  24622.         {
  24623.  
  24624.         /* variable declarations, if any */
  24625.  
  24626. If the protocol request has a reply, then the variable
  24627. declarations should include the reply structure for the
  24628. request.  The following is an example.
  24629.  
  24630.  
  24631.         xDoSomethingReply rep;
  24632.  
  24633.  
  24634.  
  24635.                      December 18, 1987
  24636.  
  24637.  
  24638.  
  24639.  
  24640.  
  24641.                           - 362 -
  24642.  
  24643.  
  24644. Locking Data Structures
  24645.  
  24646.                             Note
  24647.  
  24648.      Locking has not yet been tested as of September 2,
  24649.      1987!
  24650.  
  24651.  
  24652. In order to lock the display structure, for systems which
  24653. want to support multithreaded access to a single display
  24654. connection, each stub will need to lock its critical sec-
  24655. tion.  Generally, this section is the point from just before
  24656. the appropriate GetReq call documented below and when all
  24657. arguments to the call have been stored into the request.
  24658. The precise instructions needed for this locking depend upon
  24659. the machine architecture. Two calls, which are generally
  24660. implemented as macros, have been provided.
  24661.  
  24662. LockDisplay(display)
  24663.       Display *display;
  24664.  
  24665.  
  24666. UnlockDisplay(display)
  24667.       Display *display;
  24668.  
  24669.  
  24670. Sending the Protocol Request and Arguments
  24671.  
  24672. After the variable declarations, a stub routine should call
  24673. one of four macros defined in Xlibint.h:  GetReq, GetReqEx-
  24674. tra, GetResReq, or GetEmptyReq.  All of these macros take as
  24675. their first argument the name of the protocol request as
  24676. declared in Xproto.h, except with "X_" removed. Each one
  24677. declares a Display structure pointer, called ``dpy'', and a
  24678. pointer to a request structure, called ``req'', which is of
  24679. the appropriate type. The macro then appends the request
  24680. structure to the output buffer, fills in its type and length
  24681. field, and sets "req" to point to it.
  24682.  
  24683. If the protocol request has no arguments (for instance,
  24684. X_GrabServer), then use GetEmptyReq:
  24685.  
  24686.  
  24687.         GetEmptyReq (DoSomething);
  24688.  
  24689. If the protocol request has a single 32-bit argument (such
  24690. as, a Pixmap, Window, Drawable, Atom, and so on), then use
  24691. GetResReq.  The second argument to the macro is the 32-bit
  24692. object. X_MapWindow is a good example.
  24693.  
  24694.  
  24695.         GetResReq (DoSomething, rid);
  24696.  
  24697. The rid argument is the Pixmap, Window, or other resource
  24698.  
  24699.  
  24700.  
  24701.                      December 18, 1987
  24702.  
  24703.  
  24704.  
  24705.  
  24706.  
  24707.                           - 363 -
  24708.  
  24709.  
  24710. ID.
  24711.  
  24712. If the protocol request takes any other argument list, then
  24713. call GetReq.  After the GetReq, you need to set all the
  24714. other fields in the request structure, usually from argu-
  24715. ments to the stub routine.
  24716.  
  24717.  
  24718.         GetReq (DoSomething);
  24719.         /* fill in arguments here */
  24720.         req->arg1 = arg1;
  24721.         req->arg2 = arg2;
  24722.  
  24723. A few stub routines (such as, XCreateGC and XCreatePixmap)
  24724. return a resource ID to the caller but pass a resource ID as
  24725. an argument to the protocol request. Such routines use the
  24726. macro XAllocID to allocate a resource ID from the range of
  24727. IDs that were assigned to this client when it opened the
  24728. connection.
  24729.  
  24730.  
  24731.         rid = req->rid = XAllocID();
  24732.         return (rid);
  24733.  
  24734. Finally, some stub routines transmit a fixed amount of
  24735. variable-length data after the request. Typically, these are
  24736. routines (such as, XMoveWindow and XSetBackgroundPixel) are
  24737. special cases of more general functions like XMoveResizeWin-
  24738. dow and XChangeGC.  These special case routines use
  24739. GetReqExtra, which is the same as GetReq, except that it
  24740. takes an additional argument (the number of extra bytes to
  24741. allocate in the output buffer after the request structure).
  24742. This number should always be a multiple of 4.
  24743.  
  24744. Variable Length Arguments
  24745.  
  24746. Some protocol requests take additional variable length data
  24747. that follow the xDoSomethingReq structure. The format of
  24748. these data varies from request to request. Some require a
  24749. sequence of 8-bit bytes, others a sequence of 16- or 32-bit
  24750. entities, and still others a sequence of structures.
  24751.  
  24752. It is necessary to add the length of any variable length
  24753. data to the length field of the request structure. That
  24754. length field is in units of 32-bit longwords. If the data is
  24755. a string or other sequence of 8-bit bytes, then you must
  24756. round the length up and shift it before adding:
  24757.  
  24758.  
  24759.         req->length += (nbytes+3)>>2;
  24760.  
  24761. To transmit the variable length data, use the Data macro. If
  24762. the data fits into the output buffer, then this macro copies
  24763. it to the buffer. If it does not fit, however, the Data
  24764.  
  24765.  
  24766.  
  24767.                      December 18, 1987
  24768.  
  24769.  
  24770.  
  24771.  
  24772.  
  24773.                           - 364 -
  24774.  
  24775.  
  24776. macro calls _XSend, which transmits first the contents of
  24777. the buffer and then your data.  The Data macro takes three
  24778. arguments: the Display, a pointer to the beginning of the
  24779. data, and the number of bytes to be sent.
  24780. Data(dpy, (char *) data, nbytes);
  24781.  
  24782. If the data are 16-bit entities, then use the PackData macro
  24783. instead.  It takes the same arguments and does the same
  24784. things, but it does the right thing on machines where a
  24785. short is 32-bits instead of the usual 16.
  24786.  
  24787. Both Data and PackData are macros which may use their last
  24788. argument more than once, so that argument should be a vari-
  24789. able rather than an expression such as
  24790. ``nitems*sizeof(item)''. You should do that kind of computa-
  24791. tion in a separate statement before calling Data.
  24792.  
  24793. If the protocol request requires a reply, then call the pro-
  24794. cedure _XSend instead of the Data macro. _XSend takes the
  24795. same arguments, but, because it sends your data immediately
  24796. instead of copying it into the output buffer (which would
  24797. later be flushed anyway by the following call on _XReply),
  24798. it is faster.
  24799.  
  24800. Replies
  24801.  
  24802. If the protocol request has a reply, then call _XReply after
  24803. you have finished dealing with all the fixed and variable
  24804. length arguments. _XReply flushes the output buffer and
  24805. waits for an xReply packet to arrive. If any events arrive
  24806. in the meantime, _XReply enqueues them for later use.
  24807.  
  24808. Status _XReply(display, rep, extra, discard)
  24809.       Display *display;
  24810.       xReply *rep;
  24811.       int extra;              /* number of 32-bit words expected after the reply */
  24812.       Bool discard;           /* should I discard data following "extra" words? */
  24813.  
  24814. _XReply waits for a reply packet and copies its contents
  24815. into the specified rep. _XReply handles error and event
  24816. packets that occur before the reply is received.  _XReply
  24817. takes four arguments:
  24818.  
  24819. o    A Display * structure
  24820.  
  24821. o    A pointer to an reply structure (which must be cast to
  24822.      an xReply *)
  24823.  
  24824. o    The number of additional bytes (beyond sizeof(xReply) =
  24825.      32 bytes) in the reply structure
  24826.  
  24827. o    A boolean which tells _XReply to discard any additional
  24828.      bytes beyond those it was told to read
  24829.  
  24830.  
  24831.  
  24832.  
  24833.                      December 18, 1987
  24834.  
  24835.  
  24836.  
  24837.  
  24838.  
  24839.                           - 365 -
  24840.  
  24841.  
  24842. Because most reply structures are 32 bytes long, the third
  24843. argument is usually 0. The only exceptions are the replies
  24844. to GetWindowAttributes, QueryFont, QueryKeymap, and GetKey-
  24845. boardControl in the core protocol, which have longer
  24846. replies.
  24847.  
  24848. The last argument should be xFalse, if the reply structure
  24849. is followed by additional variable length data (such as, a
  24850. list or string). It should be xTrue if there is not any
  24851. variable length data.
  24852.  
  24853.                             Note
  24854.  
  24855.      This last argument is provided for upward-
  24856.      compatibility reasons--to allow a client to com-
  24857.      municate properly with a hypothetical later ver-
  24858.      sion of the server which sends more data than the
  24859.      client expected.  For example, some later version
  24860.      of GetWindowAttributes might use a larger, but
  24861.      compatible, xGetWindowAttributesReply which con-
  24862.      tains additional attribute data at the end.
  24863.  
  24864. _XReply returns true, if it received a reply successfully,
  24865. or false, if it received an XError instead (or some other
  24866. error condition occurred).
  24867.  
  24868. For a request with a reply that is not followed by variable
  24869. length data, you write something like:
  24870.  
  24871.  
  24872.         _XReply (display, (xReply *)&rep, 0, xTrue);
  24873.         *ret1 = rep.ret1;
  24874.         *ret2 = rep.ret2;
  24875.         *ret3 = rep.ret3;
  24876.         UnlockDisplay(dpy);
  24877.         SyncHandle();
  24878.         return (rep.ret4);
  24879.         }
  24880.  
  24881. If there is variable length data after the reply, change the
  24882. ``xTrue'' to ``xFalse'', and use _XRead to read the
  24883. variable-length data.
  24884.  
  24885. Each protocol request is a little different. For further
  24886. information, see the Xlib sources for examples.
  24887.  
  24888. Synchronous Calling
  24889.  
  24890. To ease debugging, each routine should have a call to a rou-
  24891. tine, just before returning to the user, called SyncHan-
  24892. dle().  This routine generally is implemented as a macro.
  24893. If synchronous mode is enabled (see XSynchronize), the
  24894. request is sent immediately.  The library, however, waits
  24895. until any error the routine could generate at the server has
  24896.  
  24897.  
  24898.  
  24899.                      December 18, 1987
  24900.  
  24901.  
  24902.  
  24903.  
  24904.  
  24905.                           - 366 -
  24906.  
  24907.  
  24908. been handled.
  24909.  
  24910. Allocating and Deallocating Memory
  24911.  
  24912. To support the possible reentrancy of these routines, you
  24913. must observe several conventions when allocating and deallo-
  24914. cating memory.  This is most often done when returning data
  24915. to the user from the window system of a size the caller
  24916. could not know in advance (for example, a list of fonts or a
  24917. list of extensions).  This occurs because the standard C
  24918. library routines on many systems are not protected against
  24919. signals or other multithreaded use.  The following analogies
  24920. to standard I/O library routines have been defined:
  24921.  
  24922. Xmalloc()      Replaces malloc()
  24923. Xfree()        Replaces free()
  24924. Xcalloc()      Replaces calloc()
  24925.  
  24926. These should be used in place of any calls you would make to
  24927. the normal C library routines.
  24928.  
  24929. If you need a single scratch buffer inside a critical sec-
  24930. tion (for example, to pack and unpack data to and from wire
  24931. protocol), the general memory allocators may be too expen-
  24932. sive for use (particularly in output routines, which are
  24933. performance critical). The routine below returns a scratch
  24934. buffer for your use:
  24935.  
  24936. char *_XAllocScratch(display, nbytes)
  24937.       Display *display;
  24938.       unsigned long nbytes;
  24939.  
  24940. This storage must only be used inside of the critical sec-
  24941. tion of your stub.
  24942.  
  24943. Portability Considerations
  24944.  
  24945. Many machine architectures, including many of the more
  24946. recent RISC architectures, will not correctly access data at
  24947. unaligned locations; their compilers will pad out structures
  24948. to preserve this characteristic.  Many other machines capa-
  24949. ble of unaligned references pad inside of structures as well
  24950. to preserve alignment, since accessing aligned data is usu-
  24951. ally much faster.  Since the library and the server is using
  24952. structures to access data at arbitrary points in a byte
  24953. stream, all data in request and reply packets MUST be natur-
  24954. ally aligned; that is 16 bit data start on 16 bit boundaries
  24955. in the request, 32 bit data on 32 bit boundaries.  All
  24956. requests MUST be a multiple of 32 bits in length, to
  24957. preserve the natural alignment in the data stream.  Pad
  24958. structures out to 32 bit boundaries.  Pad information does
  24959. not have to be zeroed, unless you wish to preserve such
  24960. fields for future use in your protocol requests.  Floating
  24961. point varies radically between machines, and should be
  24962.  
  24963.  
  24964.  
  24965.                      December 18, 1987
  24966.  
  24967.  
  24968.  
  24969.  
  24970.  
  24971.                           - 367 -
  24972.  
  24973.  
  24974. avoided completely if at all possible.
  24975.  
  24976. This code may run on machines with 16-bit ``int''s. So, if
  24977. any integer argument, variable, or return value either can
  24978. take only non-negative values or is declared as a CARD16 in
  24979. the protocol, be sure to declare it as ``unsigned int'' and
  24980. not as ``int''.  (This of course does not apply to booleans
  24981. or enumerations.)
  24982.  
  24983. Similarly, if any integer argument or return value is
  24984. declared CARD32 in the protocol, declare it as an ``unsigned
  24985. long'' and not as ``int'' or ``long''.  This also goes for
  24986. any internal variables that may take on values larger than
  24987. the maximum 16-bit unsigned int.
  24988.  
  24989. The library currently assumes that a ``char'' is 8 bits, a
  24990. ``short'' is 16 bits, an ``int'' is 16 or 32 bits, and a
  24991. ``long'' is 32 bits. The PackData macro is a half-hearted
  24992. attempt to deal with the possibility of 32-bit ``shorts''.
  24993. However, much more work is needed to make this really work
  24994. properly.
  24995.  
  24996. Deriving the Correct Extension Opcode
  24997.  
  24998. The remaining problem a writer of an extension stub routine
  24999. faces that the core protocol does not face is to map from
  25000. the call to the proper major and minor opcodes. While there
  25001. are a number of strategies, the simplest and fastest is out-
  25002. lined below.
  25003.  
  25004. 1.   Declare an array of pointers, _NFILE long (this is nor-
  25005.      mally found in <stdio.h> and is the number of file
  25006.      descriptors supported on the system, of type XExtCodes.
  25007.      Make sure these are all initialized to NULL.
  25008.  
  25009. 2.   When your stub is entered, your initialization test is
  25010.      just to use the display pointer passed in to access the
  25011.      file descriptor, and an index into the array. If the
  25012.      entry is NULL, then this is the first time you are
  25013.      entering the routine for this display. Call your ini-
  25014.      tialization routine and pass it the display pointer.
  25015.  
  25016. 3.   Once in your initialization routine, call XInitExten-
  25017.      sion, and if it succeeds, store the pointer returned
  25018.      into this array. Make sure to establish a close display
  25019.      handler to allow you to zero the entry.  Do whatever
  25020.      other initialization your extension requires.  (For
  25021.      example, install event handlers, and so on).  Your ini-
  25022.      tialization routine would normally return a pointer to
  25023.      the XExtCodes structure for this extension, which is
  25024.      what would normally be found in your array of pointers.
  25025.  
  25026.  
  25027.  
  25028.  
  25029.  
  25030.  
  25031.                      December 18, 1987
  25032.  
  25033.  
  25034.  
  25035.  
  25036.  
  25037.                           - 368 -
  25038.  
  25039.  
  25040. 4.   After returning from your initialization routine, the
  25041.      stub can now continue normally, since it has its major
  25042.      opcode safely in its had in the XExtCodes structure.
  25043.  
  25044.  
  25045.  
  25046.  
  25047.  
  25048.  
  25049.  
  25050.  
  25051.  
  25052.  
  25053.  
  25054.  
  25055.  
  25056.  
  25057.  
  25058.  
  25059.  
  25060.  
  25061.  
  25062.  
  25063.  
  25064.  
  25065.  
  25066.  
  25067.  
  25068.  
  25069.  
  25070.  
  25071.  
  25072.  
  25073.  
  25074.  
  25075.  
  25076.  
  25077.  
  25078.  
  25079.  
  25080.  
  25081.  
  25082.  
  25083.  
  25084.  
  25085.  
  25086.  
  25087.  
  25088.  
  25089.  
  25090.  
  25091.  
  25092.  
  25093.  
  25094.  
  25095.  
  25096.  
  25097.                      December 18, 1987
  25098.  
  25099.  
  25100.  
  25101.  
  25102.  
  25103.                           - 369 -
  25104.  
  25105.  
  25106.  
  25107.  
  25108.                            Appendix B
  25109.  
  25110.                Version 10 Compatibility Functions
  25111.  
  25112.  
  25113.  
  25114. Drawing and Filling Polygons and Curves
  25115.  
  25116. Appendix B - Version 10 Compatibility Functions Xlib pro-
  25117. vides functions with which you can draw or fill arbitrary
  25118. polygons or curves. These functions are provided mainly for
  25119. compatibility with X10 and have no server support. That is,
  25120. they call other Xlib routines, not the server directly.
  25121. Thus, if you just have straight lines to draw, using XDraw-
  25122. Lines or XDrawSegments is much faster.
  25123.  
  25124. The functions discussed here provide all the functionality
  25125. of the X10 routines XDraw, XDrawFilled, XDrawPatterned,
  25126. XDrawDashed, and XDrawTiled.  They are as compatible as pos-
  25127. sible given X11's new line drawing routines. One thing to
  25128. note, however, is that VertexDrawLastPoint is no longer sup-
  25129. ported. Also, the error status returned is the opposite of
  25130. what it was under X10 (this is the X11 standard error
  25131. status). XAppendVertex and XClearVertexFlag from X10 also
  25132. are not supported.
  25133.  
  25134. Just how the graphics context you use is set up actually
  25135. determines whether you get dashes or not, and so on. Lines
  25136. are properly joined if they connect and include the closing
  25137. of a closed figure. (See XDrawLines in X 11 for further
  25138. details.) The functions discussed here fail (return 0) only
  25139. if they run out of memory or are passed a Vertex list which
  25140. has a Vertex with VertexStartClosed set which is not fol-
  25141. lowed by a Vertex with VertexEndClosed set.
  25142.  
  25143.  
  25144. To achieve the effects of the V10 XDraw, XDrawDashed, and
  25145. XDrawPatterned, use XDraw.
  25146.  
  25147. #include <X11/X10.h>
  25148.  
  25149. Status XDraw(display, d, gc, vlist, vcount)
  25150.           Display *display;
  25151.           Drawable d;
  25152.           GC gc;
  25153.           Vertex *vlist;
  25154.           int vcount;
  25155.  
  25156.  
  25157. display   Specifies the connection to the X server.
  25158.  
  25159.  
  25160.  
  25161.  
  25162.  
  25163.                      December 18, 1987
  25164.  
  25165.  
  25166.  
  25167.  
  25168.  
  25169.                           - 370 -
  25170.  
  25171.  
  25172. d         Specifies the drawable.
  25173.  
  25174. gc        Specifies the graphics context.
  25175.  
  25176. vlist     Specifies a pointer to the list of vertices which
  25177.           indicate what to draw.
  25178.  
  25179. vcount    Specifies how many vertices are in vlist.
  25180.  
  25181. XDraw draws an arbitrary polygon or curve. The figure drawn
  25182. is defined by the specified list of Vertexes (vlist).  The
  25183. points are connected by lines as specified in the flags in
  25184. the vertex structure.
  25185.  
  25186. Each Vertex, as defined in <X11/Xlib.h>, is a structure with
  25187. the following elements:
  25188. typedef struct _Vertex {
  25189.      short x,y;
  25190.      unsigned short flags;
  25191. } Vertex;
  25192.  
  25193. The x and y elements are the coordinates of the vertex that
  25194. are relative to either the upper left inside corner of the
  25195. drawable (if VertexRelative is 0) or the previous vertex (if
  25196. VertexRelative is 1).
  25197.  
  25198. The flags, as defined in X10.h, are as follows:
  25199.  
  25200. VertexRelative 0x0001    else absolute
  25201. VertexDontDraw 0x0002    else draw
  25202. VertexCurved   0x0004    else straight
  25203. VertexStartClosed        0x0008else not
  25204. VertexEndClosed          0x0010else not
  25205.  
  25206.  
  25207. o    If VertexRelative is not set, the coordinates are abso-
  25208.      lute (relative to the drawable). The first vertex must
  25209.      be an absolute vertex.
  25210.  
  25211. o    If VertexDontDraw is 1, no line or curve is drawn from
  25212.      the previous vertex to this one. This is analogous to
  25213.      picking up the pen and moving to another place before
  25214.      drawing another line.
  25215.  
  25216. o    If VertexCurved is 1, a spline algorithm is used to
  25217.      draw a smooth curve from the previous vertex, through
  25218.      this one, to the next vertex. Otherwise, a straight
  25219.      line is drawn from the previous vertex to this one. It
  25220.      makes sense to set VertexCurved to 1 only if a previous
  25221.      and next vertex are both defined (either explicitly in
  25222.      the array, or through the definition of a closed
  25223.      curve--see below.)
  25224.  
  25225.  
  25226.  
  25227.  
  25228.  
  25229.                      December 18, 1987
  25230.  
  25231.  
  25232.  
  25233.  
  25234.  
  25235.                           - 371 -
  25236.  
  25237.  
  25238. o    It is permissible for VertexDontDraw bits and Vertex-
  25239.      Curved bits to be both be 1. This is useful if you want
  25240.      to define the previous point for the smooth curve, but
  25241.      you do not want an actual curve drawing to start until
  25242.      this point.
  25243.  
  25244. o    If VertexStartClosed is 1, then this point marks the
  25245.      beginning of a closed curve. This vertex must be fol-
  25246.      lowed later in the array by another vertex whose abso-
  25247.      lute coordinates are identical and which has VertexEnd-
  25248.      Closed bit of 1.  The points in between from a cycle
  25249.      for the purpose of determining predecessor and succes-
  25250.      sor vertices for the spline algorithm.
  25251.  
  25252. XDraw uses the following graphics context components:  func-
  25253. tion, plane_mask, line_width, line_style, cap_style,
  25254. join_style, fill_style, subwindow_mode, clip_x_origin,
  25255. clip_y_origin, and clip_mask.  This function also uses these
  25256. graphics context mode-dependent components: foreground,
  25257. background, tile, stipple, ts_s_origin, ts_y_origin,
  25258. dash_offset, and dash_list.
  25259.  
  25260.  
  25261. To achieve the effects of the V10 XDrawTiled and
  25262. XDrawFilled, use XDrawFilled.
  25263.  
  25264. #include <X11/X10.h>
  25265.  
  25266. Status XDrawFilled(display, d, gc, vlist, vcount)
  25267.           Display *display;
  25268.           Drawable d;
  25269.           GC gc;
  25270.           Vertex *vlist;
  25271.           int vcount;
  25272.  
  25273.  
  25274. display   Specifies the connection to the X server.
  25275.  
  25276. d         Specifies the drawable.
  25277.  
  25278. gc        Specifies the graphics context.
  25279.  
  25280. vlist     Specifies a pointer to the list of vertices which
  25281.           indicate what to draw.
  25282.  
  25283. vcount    Specifies how many vertices are in vlist.
  25284.  
  25285. XDrawFilled draws arbitrary polygons or curves and then
  25286. fills them.
  25287.  
  25288. XDrawFilled uses the following graphics context components:
  25289. function, plane_mask, line_width, line_style, cap_style,
  25290. join_style, fill_style, subwindow_mode, clip_x_origin,
  25291. clip_y_origin, and clip_mask.  This function also uses these
  25292.  
  25293.  
  25294.  
  25295.                      December 18, 1987
  25296.  
  25297.  
  25298.  
  25299.  
  25300.  
  25301.                           - 372 -
  25302.  
  25303.  
  25304. graphics context mode-dependent components: foreground,
  25305. background, tile, stipple, ts_s_origin, ts_y_origin,
  25306. dash_offset, dash_list, fill_style and fill_rule.
  25307.  
  25308. Associating User Data with a Value
  25309.  
  25310. These functions have been replaced by the context management
  25311. functions.  See Section 10.12 for further information.  It
  25312. is often necessary to associate arbitrary information with
  25313. resource IDs.  Xlib provides the AssocTable functions with
  25314. which you can make such an association.  Application pro-
  25315. grams often need to be able to easily refer to their own
  25316. data structures when an event arrives.  The XAssocTable sys-
  25317. tem provides users of the X library with  a  method of asso-
  25318. ciating their own data structures with X resources.  (Bit-
  25319. maps, Pixmaps, Fonts, Windows, and so on).
  25320.  
  25321. An XAssocTable can be used to type X resources. For example,
  25322. the user may wish to have three or four `types' of windows
  25323. each with  different properties. This can be accomplished by
  25324. associating each X window ID with a pointer to a `window
  25325. property' data structure  defined  by  the user.  A generic
  25326. type has been defined in the X library for resource IDs.  It
  25327. is called ``XId''.
  25328.  
  25329. There are a few  guidelines  that  should be observed when
  25330. using an XAssocTable:
  25331.  
  25332. o    All  X IDs  are  relative  to  the  specified display.
  25333.      Therefore,  if you are using multiple displays you need
  25334.      to be sure the correct display is active before per-
  25335.      forming an XAssocTable operation.  XAssocTable imposes
  25336.      no restrictions on the number of X IDs per table, the
  25337.      number of X IDs per display or the number of displays
  25338.      per table.
  25339.  
  25340. o    Because  of  the  hashing  scheme  used  by  the  asso-
  25341.      ciation mechanism the following rules for determining
  25342.      the size of XAssocTables should be followed. Associa-
  25343.      tions will be  made  and  looked  up  more efficiently
  25344.      if  the  table  size  (number  of  buckets in the hash-
  25345.      ing system) is a power of two and if there are not more
  25346.      than 8 XIds  per bucket.
  25347.  
  25348.  
  25349. To return a pointer to a newly created assoctable, use
  25350. XCreateAssocTable.  The definition of this function is:
  25351.  
  25352. XAssocTable *XCreateAssocTable(size)
  25353.       int size;
  25354.  
  25355.  
  25356.  
  25357.  
  25358.  
  25359.  
  25360.  
  25361.                      December 18, 1987
  25362.  
  25363.  
  25364.  
  25365.  
  25366.  
  25367.                           - 373 -
  25368.  
  25369.  
  25370. size      Specifies the number of buckets in the hash system
  25371.           of XAssocTable.
  25372.  
  25373. The "size" argument specifies the number of buckets in the
  25374. hash system of XAssocTable.  For  reasons  of  efficiency
  25375. the number of buckets should be a power of two.  Some size
  25376. suggestions  might  be:  use  32 buckets  per  100  objects;
  25377. a reasonable maximum number of object per buckets is 8.   If
  25378. there  is  an  error  allocating  memory  for  the XAssocT-
  25379. able, a NULL pointer is returned.
  25380.  
  25381.  
  25382. To create an entry in a specific assoctable, use XMakeAssoc.
  25383. The definition of this function is:
  25384.  
  25385. XMakeAssoc(display, table, x_id, data)
  25386.       Display *display;
  25387.       XAssocTable *table;
  25388.       XID x_id;
  25389.       char *data;
  25390.  
  25391.  
  25392. display   Specifies the connection to the X server.
  25393.  
  25394. table     Specifies the assoc table.
  25395.  
  25396. x_id      Specifies the X resource ID.
  25397.  
  25398. data      Specifies the data to be associated with the X
  25399.           resource ID.
  25400.  
  25401. XMakeAssoc inserts data into an XAssocTable keyed  on  an
  25402. XId. Data  is inserted  into the table only once.  Redundant
  25403. inserts are meaningless and cause no problems.  The queue in
  25404. each association bucket is sorted from the lowest XId to the
  25405. highest XId.
  25406.  
  25407.  
  25408. To obtain data from a specific assoctable, use XLookUpAssoc.
  25409. The definition of this function is:
  25410.  
  25411. char *XLookUpAssoc(display, table, x_id)
  25412.       Display *display;
  25413.       XAssocTable *table;
  25414.       XID x_id;
  25415.  
  25416.  
  25417. display   Specifies the connection to the X server.
  25418.  
  25419. table     Specifies the assoc table.
  25420.  
  25421. x_id      Specifies the X resource ID.
  25422.  
  25423. XLookUpAssoc retrieves the data stored in an XAssocTable by
  25424.  
  25425.  
  25426.  
  25427.                      December 18, 1987
  25428.  
  25429.  
  25430.  
  25431.  
  25432.  
  25433.                           - 374 -
  25434.  
  25435.  
  25436. its XId. If  an appropriately  matching XId can be found in
  25437. the table the routine will return the data associated with
  25438. it. If the x_id can not be found in the table the routine
  25439. will return NULL.
  25440.  
  25441.  
  25442. To delete an entry from a specific assoctable, use
  25443. XDeleteAssoc.  The definition of this function is:
  25444.  
  25445. XDeleteAssoc(display, table, x_id)
  25446.       Display *display;
  25447.       XAssocTable *table;
  25448.       XID x_id;
  25449.  
  25450.  
  25451. display   Specifies the connection to the X server.
  25452.  
  25453. table     Specifies the assoc table.
  25454.  
  25455. x_id      Specifies the X resource ID.
  25456.  
  25457. XDeleteAssoc deletes an association in an XAssocTable keyed
  25458. on its XId.  Redundant deletes (and deletes of non-existent
  25459. XIds) are meaningless and cause no problems.  Deleting asso-
  25460. ciations in no way impairs the performance of an XAssocT-
  25461. able.
  25462.  
  25463.  
  25464. To free the memory associated with a specific assoctable,
  25465. use XDestroyAssocTable.  The definition of this function is:
  25466.  
  25467. XDestroyAssocTable(table)
  25468.       XAssocTable *table;
  25469.  
  25470.  
  25471. table     Specifies the assoc table.
  25472.  
  25473. Using an XAssocTable after it has been destroyed is
  25474. guaranteed to have unpredictable and probably disastrous
  25475. consequences!
  25476.  
  25477.  
  25478.  
  25479.  
  25480.  
  25481.  
  25482.  
  25483.  
  25484.  
  25485.  
  25486.  
  25487.  
  25488.  
  25489.  
  25490.  
  25491.  
  25492.  
  25493.                      December 18, 1987
  25494.  
  25495.  
  25496.  
  25497.  
  25498.  
  25499.                           - 375 -
  25500.  
  25501.  
  25502.  
  25503.  
  25504.                          Appendix C
  25505.  
  25506.                        X Font Cursors
  25507.  
  25508.  
  25509.  
  25510. Appendix C - X Font Cursors The following are the available
  25511. cursors and their shapes in fonts.
  25512.  
  25513. #define XC_num_glyphs 154
  25514. #define XC_X_cursor 0
  25515. #define XC_arrow 2
  25516. #define XC_based_arrow_down 4
  25517. #define XC_based_arrow_up 6
  25518. #define XC_boat 8
  25519. #define XC_bogosity 10
  25520. #define XC_bottom_left_corner 12
  25521. #define XC_bottom_right_corner 14
  25522. #define XC_bottom_side 16
  25523. #define XC_bottom_tee 18
  25524. #define XC_box_sprial 20
  25525. #define XC_center_ptr 22
  25526. #define XC_circle 24
  25527. #define XC_clock 26
  25528. #define XC_coffee_mug 28
  25529. #define XC_cross 30
  25530. #define XC_cross_reverse 32
  25531. #define XC_crosshair 34
  25532. #define XC_diamond_cross 36
  25533. #define XC_dot 38
  25534. #define XC_dot_box_mask 40
  25535. #define XC_double_arrow 42
  25536. #define XC_draft_large 44
  25537. #define XC_draft_small 46
  25538. #define XC_draped_box 48
  25539. #define XC_exchange 50
  25540. #define XC_fleur 52
  25541. #define XC_gobbler 54
  25542. #define XC_gumby 56
  25543. #define XC_hand 58
  25544. #define XC_hand1_mask 60
  25545. #define XC_heart 62
  25546. #define XC_icon 64
  25547. #define XC_iron_cross 66
  25548. #define XC_left_ptr 68
  25549. #define XC_left_side 70
  25550. #define XC_left_tee 72
  25551. #define XC_leftbutton 74
  25552. #define XC_ll_angle 76
  25553. #define XC_lr_angle 78
  25554. #define XC_man 80
  25555. #define XC_middlebutton 82
  25556.  
  25557.  
  25558.  
  25559.                      December 18, 1987
  25560.  
  25561.  
  25562.  
  25563.  
  25564.  
  25565.                           - 376 -
  25566.  
  25567.  
  25568. #define XC_mouse 84
  25569. #define XC_pencil 86
  25570. #define XC_pirate 88
  25571. #define XC_plus 90
  25572. #define XC_question_arrow 92
  25573. #define XC_right_ptr 94
  25574. #define XC_right_side 96
  25575. #define XC_right_tee 98
  25576. #define XC_rightbutton 100
  25577. #define XC_rtl_logo 102
  25578. #define XC_sailboat 104
  25579. #define XC_sb_down_arrow 106
  25580. #define XC_sb_h_double_arrow 108
  25581. #define XC_sb_left_arrow 110
  25582. #define XC_sb_right_arrow 112
  25583. #define XC_sb_up_arrow 114
  25584. #define XC_sb_v_double_arrow 116
  25585. #define XC_shuttle 118
  25586. #define XC_sizing 120
  25587. #define XC_spider 122
  25588. #define XC_spraycan 124
  25589. #define XC_star 126
  25590. #define XC_target 128
  25591. #define XC_tcross 130
  25592. #define XC_top_left_arrow 132
  25593. #define XC_top_left_corner 134
  25594. #define XC_top_right_corner 136
  25595. #define XC_top_side 138
  25596. #define XC_top_tee 140
  25597. #define XC_trek 142
  25598. #define XC_ul_angle 144
  25599. #define XC_umbrella 146
  25600. #define XC_ur_angle 148
  25601. #define XC_watch 150
  25602. #define XC_xterm 152
  25603.  
  25604.  
  25605.  
  25606.  
  25607.  
  25608.  
  25609.  
  25610.  
  25611.  
  25612.  
  25613.  
  25614.  
  25615.  
  25616.  
  25617.  
  25618.  
  25619.  
  25620.  
  25621.  
  25622.  
  25623.  
  25624.  
  25625.                      December 18, 1987
  25626.  
  25627.  
  25628.  
  25629.  
  25630.  
  25631.                           - 377 -
  25632.  
  25633.  
  25634.  
  25635.  
  25636.                          Appendix D
  25637.  
  25638.             Xlib Functions and Protocol Requests
  25639.  
  25640.  
  25641.  
  25642. Appendix D - Xlib Functions and Protocol Requests The fol-
  25643. lowing tables provide a information about Xlib and the X
  25644. protocol.  The first table lists each Xlib function (in
  25645. alphabetical order) and the corresponding protocol request
  25646. that it generates.  The second table lists each X protocol
  25647. request (in alphabetical order) and the Xlib functions that
  25648. reference it.
  25649.  
  25650.  
  25651. ______________________________________________________
  25652. Xlib Function                Protocol Request
  25653. ______________________________________________________
  25654. XActivateScreenSaver         ForceScreenSaver
  25655. XAddHost                     ChangeHosts
  25656. XAddHosts                    ChangeHosts
  25657. XAddToSaveSet                ChangeSaveSet
  25658. XAllocColor                  AllocColor
  25659. XAllocColorCells             AllocColorCells
  25660. XAllocColorPlanes            AllocColorPlanes
  25661. XAllocNamedColor             AllocNamedColor
  25662. XAllowEvents                 AllowEvents
  25663. XAutoRepeatOff               ChangeKeyboardControl
  25664. XAutoRepeatOn                ChangeKeyboardControl
  25665. XBell                        Bell
  25666. XChangeActivePointerGrab     ChangeActivePointerGrab
  25667. XChangeGC                    ChangeGC
  25668. XChangeKeyboardControl       ChangeKeyboardControl
  25669. XChangeKeyboardMapping       ChangeKeyboardMapping
  25670. XChangePointerControl        ChangePointerControl
  25671. XChangeProperty              ChangeProperty
  25672. XChangeSaveSet               ChangeSaveSet
  25673. XChangeWindowAttributes      ChangeWindowAttributes
  25674. XCirculateSubwindows         CirculateWindow
  25675. XCirculateSubwindowsDown     CirculateWindow
  25676. XCirculateSubwindowsUp       CirculateWindow
  25677. XClearArea                   ClearArea
  25678. XClearIconWindow             GetProperty
  25679. XClearWindow                 ClearArea
  25680. XConfigureWindow             ConfigureWindow
  25681. XConvertSelection            ConvertSelection
  25682. XCopyArea                    CopyArea
  25683. XCopyColormapAndFree         CopyColormapAndFree
  25684. XCopyGC                      CopyGC
  25685. XCopyPlane                   CopyPlane
  25686. XCreateColormap              CreateColormap
  25687. XCreateFontCursor            CreateGlphyCursor
  25688.  
  25689.  
  25690.                      December 18, 1987
  25691.  
  25692.  
  25693.  
  25694.  
  25695.  
  25696.                           - 378 -
  25697.  
  25698.  
  25699. ______________________________________________________
  25700. Xlib Function                Protocol Request
  25701. ______________________________________________________
  25702. XCreateGC                    CreateGC
  25703. XCreateGlyphCursor           CreateGlyphCursor
  25704. XCreatePixmap                CreatePixmap
  25705. XCreatePixmapCursor          CreateCursor
  25706. XCreateSimpleWindow          CreateWindow
  25707. XCreateWindow                CreateWindow
  25708. XDefineCursor                ChangeWindowAttributes
  25709. XDeleteProperty              DeleteProperty
  25710. XDestroySubwindows           DestroySubwindows
  25711. XDestroyWindow               DestroyWindow
  25712. XDisableAccessControl        SetAccessControl
  25713. XDrawArc                     PolyArc
  25714. XDrawArcs                    PolyArc
  25715. XDrawImageString             ImageText8
  25716. XDrawImageString16           ImageText16
  25717. XDrawLine                    PolySegment
  25718. XDrawLines                   PolyLine
  25719. XDrawPoint                   PolyPoint
  25720. XDrawPoints                  PolyPoint
  25721. XDrawRectangle               PolyRectangle
  25722. XDrawRectangles              PolyRectangle
  25723. XDrawSegments                PolySegment
  25724. XDrawString                  PolyText8
  25725. XDrawString16                PolyText16
  25726. XDrawText                    PolyText8
  25727. XDrawText16                  PolyText16
  25728. XEnableAccessControl         SetAccessControl
  25729. XFetchBytes                  GetProperty
  25730. XFetchName                   GetProperty
  25731. XFillArc                     PolyFillArc
  25732. XFillArcs                    PolyFillArc
  25733. XFillPolygon                 FillPoly
  25734. XFillRectangle               PolyFillRectangle
  25735. XFillRectangles              PolyFillRectangle
  25736. XForceScreenSaver            ForceScreenSaver
  25737. XFreeColormap                FreeColormap
  25738. XFreeColors                  FreeColors
  25739. XFreeCursor                  FreeCursor
  25740. XFreeFont                    CloseFont
  25741. XFreeGC                      FreeGC
  25742. XFreePixmap                  FreePixmap
  25743. XGetAtomName                 GetAtomName
  25744. XGetFontPath                 GetFontPath
  25745. XGetGeometry                 GetGeometry
  25746. XGetIconSizes                GetProperty
  25747. XGetIconWindow               GetProperty
  25748. XGetImage                    GetImage
  25749. XGetInputFocus               GetInputFocus
  25750. XGetKeyboardContol           GetKeyboardControl
  25751. XGetKeyboardMapping          GetKeyboardMapping
  25752. XGetMotionEvents             GetMotionEvents
  25753.  
  25754.  
  25755.                      December 18, 1987
  25756.  
  25757.  
  25758.  
  25759.  
  25760.  
  25761.                           - 379 -
  25762.  
  25763.  
  25764. ______________________________________________________
  25765. Xlib Function                Protocol Request
  25766. ______________________________________________________
  25767. XGetNormalHints              GetProperty
  25768. XGetPointerContol            GetPointerControl
  25769. XGetPonterMapping            GetPointerMapping
  25770. XGetScreenSaver              SetScreenSaver
  25771. XGetSelectionOwner           GetSelectionOwner
  25772. XGetSizeHints                GetProperty
  25773. XGetWMHints                  GetProperty
  25774. XGetWindowAttributes         GetWindowAttributes
  25775. XGetWindowAttributes         GetGeometry
  25776. XGetWindowProperty           GetProperty
  25777. XGetZoomHints                GetProperty
  25778. XGrabButton                  GrabButton
  25779. XGrabKey                     GrabKey
  25780. XGrabKeyboard                GrabKeyboard
  25781. XGrabPointer                 GrabPointer
  25782. XGrabServer                  GrabServer
  25783. XInitExtension               QueryExtension
  25784. XInstallColormap             InstallColormap
  25785. XInternAtom                  InternAtom
  25786. XKillClient                  KillClient
  25787. XListExtensions              ListExtensions
  25788. XListFonts                   ListFonts
  25789. XListFontsWithInfo           ListFontsWithInfo
  25790. XListHosts                   ListHosts
  25791. XListInstalledColormaps      ListInstalledColormaps
  25792. XListProperties              ListProperties
  25793. XLoadFont                    OpenFont
  25794. XLoadQueryFont               OpenFont
  25795.                              QueryFont
  25796. XLookupColor                 LookupColor
  25797. XLowerWindow                 ConfigureWindow
  25798. XMapRaised                   ConfigureWindow
  25799.                              MapWindow
  25800. XMapSubwindows               MapSubwindows
  25801. XMapWindow                   MapWindow
  25802. XMoveResizeWindow            ConfigureWindow
  25803. XMoveWindow                  ConfigureWindow
  25804. XNoOp                        NoOperation
  25805. XOpenDisplay                 CreateGC
  25806. XParseColor                  LookupColor
  25807. XPutImage                    PutImage
  25808. XQueryBestCursor             QueryBestSize
  25809. XQueryBestSize               QueryBestSize
  25810. XQueryBestStipple            QueryBestSize
  25811. XQueryBestTile               QueryBestSize
  25812. XQueryColor                  QueryColors
  25813. XQueryColors                 QueryColors
  25814. XQueryExtension              QueryExtension
  25815. XQueryKeymap                 QueryKeymap
  25816. XQueryPointer                QueryPointer
  25817. XQueryTextExtents            QueryTextExtents
  25818.  
  25819.  
  25820.                      December 18, 1987
  25821.  
  25822.  
  25823.  
  25824.  
  25825.  
  25826.                           - 380 -
  25827.  
  25828.  
  25829. ______________________________________________________
  25830. Xlib Function                Protocol Request
  25831. ______________________________________________________
  25832. XQueryTextExtents16          QueryTextExtents
  25833. XQueryTree                   QueryTree
  25834. XRaiseWindow                 ConfigureWindow
  25835. XRecolorCursor               RecolorCursor
  25836. XRemoveFromSaveSet           ChangeSaveSet
  25837. XRemoveHost                  ChangeHosts
  25838. XRemoveHosts                 ChangeHosts
  25839. XReparentWindow              ReparentWindow
  25840. XResetScreenSaver            ForceScreenSaver
  25841. XResizeWindow                ConfigureWindow
  25842. XRestackWindows              ConfigureWindow
  25843. XRotateBuffers               RotateProperties
  25844. XRotateWindowProperties      RotateProperties
  25845. XSelectInput                 ChangeWindowAttributes
  25846. XSendEvent                   SendEvent
  25847. XSetAccessControl            SetAccessControl
  25848. XSetArcMode                  ChangeGC
  25849. XSetBackground               ChangeGC
  25850. XSetClipMask                 ChangeGC
  25851. XSetClipOrigin               ChangeGC
  25852. XSetClipRectangles           SetClipRectangles
  25853. XSetCloseDownMode            SetCloseDownMode
  25854. XSetCommand                  ChangeProperty
  25855. XSetDashes                   SetDashes
  25856. XSetFillRule                 ChangeGC
  25857. XSetFillStyle                ChangeGC
  25858. XSetFont                     ChangeGC
  25859. XSetFontPath                 SetFontPath
  25860. XSetForeground               ChangeGC
  25861. XSetFunction                 ChangeGC
  25862. XSetGraphicsExposures        ChangeGC
  25863. XSetIconSizes                ChangeProperty
  25864. XSetIconWindow               ChangeProperty
  25865. XSetInputFocus               SetInputFocus
  25866. XSetLineAttributes           ChangeGC
  25867. XSetModifierMapping          SetModifierMapping
  25868. XSetNormalHints              ChangeProperty
  25869. XSetPlaneMask                ChangeGC
  25870. XSetPointerMapping           SetPointerMapping
  25871. XSetResizeHint               ChangeProperty
  25872. XSetScreenSaver              SetScreenSaver
  25873. XSetSelectionOwner           SetSelectionOwner
  25874. XSetSizeHints                ChangeProperty
  25875. XSetStandardProperties       ChangeProperty
  25876. XSetState                    ChangeGC
  25877. XSetStipple                  ChangeGC
  25878. XSetSubwindowMode            ChangeGC
  25879. XSetTile                     ChangeGC
  25880. XSetTSOrigin                 ChangeGC
  25881. XSetWMHints                  ChangeProperty
  25882. XSetWindowBackground         ChangeWindowAttributes
  25883.  
  25884.  
  25885.                      December 18, 1987
  25886.  
  25887.  
  25888.  
  25889.  
  25890.  
  25891.                           - 381 -
  25892.  
  25893.  
  25894. ______________________________________________________
  25895. Xlib Function                Protocol Request
  25896. ______________________________________________________
  25897. XSetWindowBackgroundPixmap   ChangeWindowAttributes
  25898. XSetWindowBorder             ChangeWindowAttributes
  25899. XSetWindowBorderPixmap       ChangeWindowAttributes
  25900. XSetWindowBorderWidth        ConfigureWindow
  25901. XSetWindowColormap           ChangeWindowAttributes
  25902. XSetZoomHints                ChangeProperty
  25903. XStoreBuffer                 ChangeProperty
  25904. XStoreBytes                  ChangeProperty
  25905. XStoreColor                  StoreColors
  25906. XStoreColors                 StoreColors
  25907. XStoreName                   ChangeProperty
  25908. XStoreNamedColor             StoreNamedColor
  25909. XSync                        GetInputFocus
  25910. XTranslateCoordinates        TranslateCoordinates
  25911. XUndefineCursor              ChangeWindowAttributes
  25912. XUngrabButton                UngrabButton
  25913. XUngrabKey                   UngrabKey
  25914. XUngrabKeyboard              UngrabKeyboard
  25915. XUngrabPointer               UngrabPointer
  25916. XUngrabServer                UngrabServer
  25917. XUninstallColormap           UninstallColormap
  25918. XUnloadFont                  CloseFont
  25919. XUnmapSubwindows             UnmapSubwindows
  25920. XUnmapWindow                 UnmapWindow
  25921. XWarpPointer                 WarpPointer
  25922.  
  25923.  
  25924.  
  25925.  
  25926.  
  25927.  
  25928.  
  25929.  
  25930.  
  25931.  
  25932.  
  25933.  
  25934.  
  25935.  
  25936.  
  25937.  
  25938.  
  25939.  
  25940.  
  25941.  
  25942.  
  25943.  
  25944.  
  25945.  
  25946.  
  25947.  
  25948.  
  25949.  
  25950.                      December 18, 1987
  25951.  
  25952.  
  25953.  
  25954.  
  25955.  
  25956.                           - 382 -
  25957.  
  25958.  
  25959. ______________________________________________________
  25960. Protocol Request            Xlib Function
  25961. ______________________________________________________
  25962. AllocColor                  XAllocColor
  25963. AllocColorCells             XAllocColorCells
  25964. AllocColorPlanes            XAllocColorPlanes
  25965. AllocNamedColor             XAllocNamedColor
  25966. AllowEvents                 XAllowEvents
  25967. Bell                        XBell
  25968. SetAccessControl            XDisableAccessControl
  25969.                             XEnableAccessControl
  25970.                             XSetAccessControl
  25971. ChangeActivePointerGrab     XChangeActivePointerGrab
  25972. SetCloseDownMode            XSetCloseDownMode
  25973. ChangeGC                    XChangeGC
  25974.                             XSetArcMode
  25975.                             XSetBackground
  25976.                             XSetClipMask
  25977.                             XSetClipOrigin
  25978.                             XSetFillRule
  25979.                             XSetFillStyle
  25980.                             XSetFont
  25981.                             XSetForeground
  25982.                             XSetFunction
  25983.                             XSetGraphicsExposures
  25984.                             XSetLineAttributes
  25985.                             XSetPlaneMask
  25986.                             XSetState
  25987.                             XSetStipple
  25988.                             XSetSubwindowMode
  25989.                             XSetTile
  25990.                             XSetTSOrigin
  25991. ChangeHosts                 XAddHost
  25992.                             XAddHosts
  25993.                             XRemoveHost
  25994.                             XRemoveHosts
  25995. ChangeKeyboardControl       XAutoRepeatOff
  25996.                             XAutoRepeatOn
  25997.                             XChangeKeyboardControl
  25998. ChangeKeyboardMapping       XChangeKeyboardMapping
  25999. ChangePointerControl        XChangePointerControl
  26000. ChangeProperty              XChangeProperty
  26001.                             XSetCommand
  26002.                             XSetIconSizes
  26003.                             XSetIconWindow
  26004.                             XSetNormalHints
  26005.                             XSetResizeHint
  26006.                             XSetSizeHints
  26007.                             XSetStandardProperties
  26008.                             XSetWMHints
  26009.                             XSetZoomHints
  26010.                             XStoreBuffer
  26011.                             XStoreBytes
  26012.                             XStoreName
  26013.  
  26014.  
  26015.                      December 18, 1987
  26016.  
  26017.  
  26018.  
  26019.  
  26020.  
  26021.                           - 383 -
  26022.  
  26023.  
  26024. ______________________________________________________
  26025. Protocol Request            Xlib Function
  26026. ______________________________________________________
  26027. ChangeSaveSet               XAddToSaveSet
  26028.                             XChangeSaveSet
  26029.                             XRemoveFromSaveSet
  26030. ChangeWindowAttributes      XChangeWindowAttributes
  26031.                             XDefineCursor
  26032.                             XSelectInput
  26033.                             XSetWindowBackground
  26034.                             XSetWindowBackgroundPixmap
  26035.                             XSetWindowBorder
  26036.                             XSetWindowBorderPixmap
  26037.                             XSetWindowColormap
  26038.                             XUndefineCursor
  26039. CirculateWindow             XCirculateSubwindowsDown
  26040.                             XCirculateSubwindowsUp
  26041.                             XCirculateSubwindows
  26042. ClearArea                   XClearArea
  26043.                             XClearWindow
  26044. CloseFont                   XFreeFont
  26045.                             XUnloadFont
  26046. ConfigureWindow             XConfigureWindow
  26047.                             XLowerWindow
  26048.                             XMapRaised
  26049.                             XMoveResizeWindow
  26050.                             XMoveWindow
  26051.                             XRaiseWindow
  26052.                             XResizeWindow
  26053.                             XRestackWindows
  26054.                             XSetWindowBorderWidth
  26055. ConvertSelection            XConvertSelection
  26056. CopyArea                    XCopyArea
  26057. CopyColormapAndFree         XCopyColormapAndFree
  26058. CopyGC                      XCopyGC
  26059. CopyPlane                   XCopyPlane
  26060. CreateColormap              XCreateColormap
  26061. CreateCursor                XCreatePixmapCursor
  26062. CreateGC                    XCreateGC
  26063.                             XOpenDisplay
  26064. CreateGlphyCursor           XCreateFontCursor
  26065.                             XCreateGlyphCursor
  26066. CreatePixmap                XCreatePixmap
  26067. CreateWindow                XCreateSimpleWindow
  26068.                             XCreateWindow
  26069. DeleteProperty              XDeleteProperty
  26070. DestroySubwindows           XDestroySubwindows
  26071. DestroyWindow               XDestroyWindow
  26072. FillPoly                    XFillPolygon
  26073. ForceScreenSaver            XActivateScreenSaver
  26074.                             XForceScreenSaver
  26075.                             XResetScreenSaver
  26076. FreeColormap                XFreeColormap
  26077. FreeColors                  XFreeColors
  26078.  
  26079.  
  26080.                      December 18, 1987
  26081.  
  26082.  
  26083.  
  26084.  
  26085.  
  26086.                           - 384 -
  26087.  
  26088.  
  26089. ______________________________________________________
  26090. Protocol Request            Xlib Function
  26091. ______________________________________________________
  26092. FreeCursor                  XFreeCursor
  26093. FreeGC                      XFreeGC
  26094. FreePixmap                  XFreePixmap
  26095. GetAtomName                 XGetAtomName
  26096. GetFontPath                 XGetFontPath
  26097. GetGeometry                 XGetGeometry
  26098.                             XGetWindowAttributes
  26099. GetImage                    XGetImage
  26100. GetInputFocus               XGetInputFocus
  26101.                             XSync
  26102. GetKeyboardControl          XGetKeyboardContol
  26103. GetKeyboardMapping          XGetKeyboardMapping
  26104. GetMotionEvents             XGetMotionEvents
  26105. GetPointerControl           XGetPointerContol
  26106. GetPointerMapping           XGetPonterMapping
  26107. GetProperty                 XClearIconWindow
  26108.                             XFetchBytes
  26109.                             XFetchName
  26110.                             XGetIconSizes
  26111.                             XGetIconWindow
  26112.                             XGetNormalHints
  26113.                             XGetSizeHints
  26114.                             XGetWMHints
  26115.                             XGetWindowProperty
  26116.                             XGetZoomHints
  26117. GetSelectionOwner           XGetSelectionOwner
  26118. GetWindowAttributes         XGetWindowAttributes
  26119. GrabButton                  XGrabButton
  26120. GrabKey                     XGrabKey
  26121. GrabKeyboard                XGrabKeyboard
  26122. GrabPointer                 XGrabPointer
  26123. GrabServer                  XGrabServer
  26124. ImageText16                 XDrawImageString16
  26125. ImageText8                  XDrawImageString
  26126. InstallColormap             XInstallColormap
  26127. InternAtom                  XInternAtom
  26128. KillClient                  XKillClient
  26129. ListExtensions              XListExtensions
  26130. ListFonts                   XListFonts
  26131. ListFontsWithInfo           XListFontsWithInfo
  26132. ListHosts                   XListHosts
  26133. ListInstalledColormaps      XListInstalledColormaps
  26134. ListProperties              XListProperties
  26135. LookupColor                 XLookupColor
  26136.                             XParseColor
  26137. MapSubwindows               XMapSubwindows
  26138. MapWindow                   XMapRaised
  26139.                             XMapWindow
  26140. NoOperation                 XNoOp
  26141. OpenFont                    XLoadFont
  26142.                             XLoadQueryFont
  26143.  
  26144.  
  26145.                      December 18, 1987
  26146.  
  26147.  
  26148.  
  26149.  
  26150.  
  26151.                           - 385 -
  26152.  
  26153.  
  26154. ______________________________________________________
  26155. Protocol Request            Xlib Function
  26156. ______________________________________________________
  26157. PolyArc                     XDrawArc
  26158.                             XDrawArcs
  26159. PolyFillArc                 XFillArc
  26160.                             XFillArcs
  26161. PolyFillRectangle           XFillRectangle
  26162.                             XFillRectangles
  26163. PolyLine                    XDrawLines
  26164. PolyPoint                   XDrawPoint
  26165.                             XDrawPoints
  26166. PolyRectangle               XDrawRectangle
  26167.                             XDrawRectangles
  26168. PolySegment                 XDrawLine
  26169.                             XDrawSegments
  26170. PolyText16                  XDrawString16
  26171.                             XDrawText16
  26172. PolyText8                   XDrawString
  26173.                             XDrawText
  26174. PutImage                    XPutImage
  26175. QueryBestSize               XQueryBestCursor
  26176.                             XQueryBestSize
  26177.                             XQueryBestStipple
  26178.                             XQueryBestTile
  26179. QueryColors                 XQueryColor
  26180.                             XQueryColors
  26181. QueryExtension              XInitExtension
  26182.                             XQueryExtension
  26183. QueryFont                   XLoadQueryFont
  26184. QueryKeymap                 XQueryKeymap
  26185. QueryPointer                XQueryPointer
  26186. QueryTextExtents            XQueryTextExtents
  26187.                             XQueryTextExtents16
  26188. QueryTree                   XQueryTree
  26189. RecolorCursor               XRecolorCursor
  26190. ReparentWindow              XReparentWindow
  26191. RotateProperties            XRotateBuffers
  26192.                             XRotateWindowProperties
  26193. SendEvent                   XSendEvent
  26194. SetClipRectangles           XSetClipRectangles
  26195. SetCloseDownMode            XSetCloseDownMode
  26196. SetDashes                   XSetDashes
  26197. SetFontPath                 XSetFontPath
  26198. SetInputFocus               XSetInputFocus
  26199. SetModifierMapping          XSetModifierMapping
  26200. SetPointerMapping           XSetPointerMapping
  26201. SetScreenSaver              XGetScreenSaver
  26202.                             XSetScreenSaver
  26203. SetSelectionOwner           XSetSelectionOwner
  26204. StoreColors                 XStoreColor
  26205.                             XStoreColors
  26206. StoreNamedColor             XStoreNamedColor
  26207. TranslateCoordinates        XTranslateCoordinates
  26208.  
  26209.  
  26210.                      December 18, 1987
  26211.  
  26212.  
  26213.  
  26214.  
  26215.  
  26216.                           - 386 -
  26217.  
  26218.  
  26219. ______________________________________________________
  26220. Protocol Request            Xlib Function
  26221. ______________________________________________________
  26222. UngrabButton                XUngrabButton
  26223. UngrabKey                   XUngrabKey
  26224. UngrabKeyboard              XUngrabKeyboard
  26225. UngrabPointer               XUngrabPointer
  26226. UngrabServer                XUngrabServer
  26227. UninstallColormap           XUninstallColormap
  26228. UnmapSubwindows             XUnmapSubWindows
  26229. UnmapWindow                 XUnmapWindow
  26230. WarpPointer                 XWarpPointer
  26231.  
  26232.  
  26233.  
  26234.  
  26235.  
  26236.  
  26237.  
  26238.  
  26239.  
  26240.  
  26241.  
  26242.  
  26243.  
  26244.  
  26245.  
  26246.  
  26247.  
  26248.  
  26249.  
  26250.  
  26251.  
  26252.  
  26253.  
  26254.  
  26255.  
  26256.  
  26257.  
  26258.  
  26259.  
  26260.  
  26261.  
  26262.  
  26263.  
  26264.  
  26265.  
  26266.  
  26267.  
  26268.  
  26269.  
  26270.  
  26271.  
  26272.  
  26273.  
  26274.  
  26275.                      December 18, 1987
  26276.  
  26277.  
  26278.  
  26279.  
  26280.  
  26281.                           - 387 -
  26282.  
  26283.  
  26284.  Glossary
  26285.  
  26286.                           Glossary
  26287.  
  26288.  
  26289.  
  26290. access control list
  26291.  
  26292.      X maintains a list of hosts from which client programs
  26293.      may be run. By default, only programs on the local host
  26294.      may use the display, plus any hosts specified in an
  26295.      initial list read by the server. This ``access control
  26296.      list'' can be changed by clients on the local host.
  26297.      Some server implementations may also implement other
  26298.      authorization mechanisms in addition to or in place of
  26299.      this mechanism.  The action of this mechanism may be
  26300.      conditional based on the authorization protocol name
  26301.      and data received by the server at connection setup.
  26302.  
  26303. active grab
  26304.  
  26305.      A grab is "active" when the pointer or keyboard is
  26306.      actually owned by the single grabbing client.
  26307.  
  26308. ancestor
  26309.  
  26310.      If W is an inferior of A, then A is an ``ancestor'' of
  26311.      W.
  26312.  
  26313. atom
  26314.  
  26315.      An ``atom'' is a unique ID corresponding to a string
  26316.      name.  Atoms are used to identify properties, types,
  26317.      and selections.
  26318.  
  26319. background
  26320.  
  26321.      Windows may have a ``background''. If a window has a
  26322.      background, it can either be a solid background or a
  26323.      tile pattern, and it will be repainted automatically by
  26324.      the server.
  26325.  
  26326. backing store
  26327.  
  26328.      When a server maintains the contents of a window, the
  26329.      off-screen saved pixels are known as a ``backing
  26330.      store''.
  26331.  
  26332. bit gravity
  26333.  
  26334.      When a window is resized, the contents of the window
  26335.      are not necessarily discarded. It is possible to
  26336.      request the server (though no guarantees are made) to
  26337.      relocate the previous contents to some region of the
  26338.  
  26339.  
  26340.  
  26341.                      December 18, 1987
  26342.  
  26343.  
  26344.  
  26345.  
  26346.  
  26347.                           - 388 -
  26348.  
  26349.  
  26350.      window. This attraction of window contents for some
  26351.      location of a window is known as ``bit gravity''.
  26352.  
  26353. bit plane
  26354.  
  26355.      On a color display, each pixel has more than one bit
  26356.      defined.  Data in display memory can be thought of
  26357.      either as pixels (multiple bits per pixel) or as bit
  26358.      planes (one bit plane for each usable bit in the
  26359.      pixel).
  26360.  
  26361. bitmap
  26362.  
  26363.      A ``bitmap'' is a pixmap of depth one.
  26364.  
  26365. border
  26366.  
  26367.      Windows can have borders that are zero (0) or more pix-
  26368.      els wide.  If a window has a border, the border can be
  26369.      a solid color or a tile pattern, and it will be
  26370.      repainted automatically by the server.
  26371.  
  26372. button grabbing
  26373.  
  26374.      Buttons on the pointer may be passively ``grabbed'' by
  26375.      a client.  When the button is pressed, the pointer is
  26376.      then actively grabbed by the client.
  26377.  
  26378. byte order
  26379.  
  26380.      For image (pixmap/bitmap) data, byte order is defined
  26381.      by the server, and clients with different native byte
  26382.      ordering must swap bytes as necessary. For all other
  26383.      parts of the protocol, the byte order is defined by the
  26384.      client, and the server swaps bytes as necessary.
  26385.  
  26386. children
  26387.  
  26388.      The ``children'' of a window are its first-level
  26389.      subwindows.
  26390.  
  26391. class
  26392.  
  26393.      Windows can be of different types.  See the entries for
  26394.      `` InputOnly '.PN "InputOutput" windows'' for further
  26395.      information about valid window types.
  26396.  
  26397. client
  26398.  
  26399.      An application program connects to the window system
  26400.      server by some interprocess communication (IPC) path,
  26401.      such as a TCP connection or a shared memory buffer.
  26402.      This program is referred to as a ``client'' of the win-
  26403.      dow system server. More precisely, the client is the
  26404.  
  26405.  
  26406.  
  26407.                      December 18, 1987
  26408.  
  26409.  
  26410.  
  26411.  
  26412.  
  26413.                           - 389 -
  26414.  
  26415.  
  26416.      IPC path itself. A program with multiple paths open to
  26417.      the server is viewed as multiple clients by the proto-
  26418.      col. Resource lifetimes are controlled by connection
  26419.      lifetimes, not by program lifetimes.
  26420.  
  26421. clipping region
  26422.  
  26423.      In a graphics context, a bitmap or list of rectangles
  26424.      can be specified to restrict output to a particular
  26425.      region of the window. The image defined by the bitmap
  26426.      or rectangles is called a ``clipping region''.
  26427.  
  26428. color map
  26429.  
  26430.      A ``color map'' consists of a set of entries defining
  26431.      color values.  The color map associated with a window
  26432.      is used to display the contents of the window; each
  26433.      pixel value indexes the color map to produce RGB values
  26434.      that drive the guns of a monitor.  Depending on
  26435.      hardware limitations, one or more color maps may be
  26436.      installed at one time, such that windows associated
  26437.      with those maps display with true colors.
  26438.  
  26439. connection
  26440.  
  26441.      The IPC path between the server and client program is
  26442.      known as a ``connection''. A client program typically
  26443.      (but not necessarily) has one connection to the server
  26444.      over which requests and events are sent.
  26445.  
  26446. containment
  26447.  
  26448.      A window ``contains'' the pointer if the window is
  26449.      viewable and the hotspot of the cursor is within a
  26450.      visible region of the window or a visible region of one
  26451.      of its inferiors. The border of the window is included
  26452.      as part of the window for containment. The pointer is
  26453.      ``in'' a window if the window contains the pointer but
  26454.      no inferior contains the pointer.
  26455.  
  26456. coordinate system
  26457.  
  26458.      The coordinate system has X horizontal and Y vertical,
  26459.      with the origin [0, 0] at the upper left. Coordinates
  26460.      are discrete, and in terms of pixels. Each window and
  26461.      pixmap has its own coordinate system. For a window, the
  26462.      origin is at the inside upper left, inside the border.
  26463.  
  26464. cursor
  26465.  
  26466.      A ``cursor'' is the visible shape of the pointer on a
  26467.      screen. It consists of a hot spot, a source bitmap, a
  26468.      shape bitmap, and a pair of colors. The cursor defined
  26469.      for a window controls the visible appearance when the
  26470.  
  26471.  
  26472.  
  26473.                      December 18, 1987
  26474.  
  26475.  
  26476.  
  26477.  
  26478.  
  26479.                           - 390 -
  26480.  
  26481.  
  26482.      pointer is in that window.
  26483.  
  26484. depth
  26485.  
  26486.      The ``depth'' of a window or pixmap is the number of
  26487.      bits per pixel it has.  The depth of a graphics context
  26488.      is the depth of the drawables it can be used in con-
  26489.      junction with for graphics output.
  26490.  
  26491. device
  26492.  
  26493.      Keyboards, mice, tablets, track-balls, button boxes,
  26494.      etc. are all collectively known as input ``devices''.
  26495.      Pointers can have one or more buttons (usually, the
  26496.      most common number is three).  The core protocol only
  26497.      deals with two devices: ``the keyboard'' and ``the
  26498.      pointer''.
  26499.  
  26500. direct color
  26501.  
  26502.      A class of color map in which a pixel value is decom-
  26503.      posed into three separate subfields for indexing.  One
  26504.      subfield indexes an array to produce red intensity
  26505.      values; the second subfield indexes a second array to
  26506.      produce blue intensity values; and the third subfield
  26507.      indexes a third array to produce green intensity
  26508.      values.  The RGB (red, green, and blue) values in the
  26509.      colormap entry can be changed dynamically.
  26510.  
  26511. display
  26512.  
  26513.      A ``display'' is a set of one or more screens that are
  26514.      driven by a single X server.  The Xlib Display struc-
  26515.      ture contains all information about the particular
  26516.      display and its screens as well as the state that Xlib
  26517.      needs to communicate with the display over a particular
  26518.      connection.
  26519.  
  26520. drawable 
  26521.  
  26522.      Both windows and pixmaps may be used as sources and
  26523.      destinations in graphics operations. These are collec-
  26524.      tively known as ``drawables''.  However, an InputOnly
  26525.      window cannot be used as a source or destination in a
  26526.      graphics operation.
  26527.  
  26528. event
  26529.  
  26530.      Clients are informed of information asynchronously via
  26531.      ``events''. These events may be either asynchronously
  26532.      generated from devices, or generated as side effects of
  26533.      client requests. Events are grouped into types. Events
  26534.      are never sent to a client by the server unless the
  26535.      client has specifically asked to be informed of that
  26536.  
  26537.  
  26538.  
  26539.                      December 18, 1987
  26540.  
  26541.  
  26542.  
  26543.  
  26544.  
  26545.                           - 391 -
  26546.  
  26547.  
  26548.      type of event, but clients ndow described can force
  26549.      events to be sent to other clients. Events are typi-
  26550.      cally reported relative to a window.
  26551.  
  26552. event mask
  26553.  
  26554.      Events are requested relative to a window. The set of
  26555.      event types a client requests relative to a window is
  26556.      described by using an ``event mask''.
  26557.  
  26558. event sychronization  
  26559.  
  26560.      There are certain race conditions possible when demul-
  26561.      tiplexing device events to clients (in particular
  26562.      deciding where pointer and keyboard events should be
  26563.      sent when in the middle of window management opera-
  26564.      tions). The event synchronization mechanism allows syn-
  26565.      chronous processing of device events.
  26566.  
  26567. event propagation 
  26568.  
  26569.      Device-related events ``propagate'' from the source
  26570.      window to ancestor windows until some client has
  26571.      expressed interest in handling that type of event, or
  26572.      until the event is discarded explicitly.
  26573.  
  26574. event source
  26575.  
  26576.      The smallest window containing the pointer is the
  26577.      ``source'' of a device related event.
  26578.  
  26579. exposure event
  26580.  
  26581.      Servers do not guarantee to preserve the contents of
  26582.      windows when windows are obscured or reconfigured.
  26583.      ``Exposure'' events are sent to clients to inform them
  26584.      when contents of regions of windows have been lost.
  26585.  
  26586. extension
  26587.  
  26588.      Named ``extensions'' to the core protocol can be
  26589.      defined to extend the system. Extension to output
  26590.      requests, resources, and event types are all possible,
  26591.      and expected.
  26592.  
  26593. font
  26594.  
  26595.      A ``font'' is an array of glyphs (typically charac-
  26596.      ters). The protocol does no translation or interpreta-
  26597.      tion of character sets. The client simply indicates
  26598.      values used to index the glyph array. A font contains
  26599.      additional metric information to determine inter-glyph
  26600.      and inter-line spacing.
  26601.  
  26602.  
  26603.  
  26604.  
  26605.                      December 18, 1987
  26606.  
  26607.  
  26608.  
  26609.  
  26610.  
  26611.                           - 392 -
  26612.  
  26613.  
  26614. frozen events
  26615.  
  26616.      Clients can ``freeze'' event processing while they
  26617.      change the screen.
  26618.  
  26619. GC
  26620.  
  26621.      Shorthand for ``graphics context''.  An equivalent
  26622.      shorthand is gcontext.  See graphic context.
  26623.  
  26624. glyph
  26625.  
  26626.      A ``glyph'' is an image, typically of a character, in a
  26627.      font.
  26628.  
  26629. grab
  26630.  
  26631.      Keyboard keys, the keyboard, pointer buttons, the
  26632.      pointer, and the server can be ``grabbed'' for
  26633.      exclusive use by a client. In general, these facilities
  26634.      are not intended to be used by normal applications, but
  26635.      are intended for various input and window managers to
  26636.      implement various styles of user interfaces.
  26637.  
  26638. graphic context
  26639.  
  26640.      Various information for graphics output is stored in a
  26641.      ``graphics context'' (``GC'' or ``gcontext''), such as
  26642.      foreground pixel, background pixel, line width, clip-
  26643.      ping region, etc.  A graphics context can only be used
  26644.      with drawables that have the same root and the same
  26645.      depth as the graphics context.
  26646.  
  26647. gravity 
  26648.  
  26649.      The contents of windows, or subwindows themselves,
  26650.      have a ``gravity''.  This determines how they will be moved
  26651.      when a window ID resized.  See ``bit gravity'' and ``window
  26652.      gravity''.
  26653.  
  26654. gray scale
  26655.  
  26656.      Gray scale can be viewed as a degenerate case of pseudo
  26657.      color, in which case the red, green, and blue values in
  26658.      any given color map entry are equal, thus producing
  26659.      shades of gray.  The gray values can be changed dynami-
  26660.      cally.
  26661.  
  26662. hotspot
  26663.  
  26664.      A cursor has an associated ``hot spot'' which defines a
  26665.      point in the cursor that corresponds to the coordinates
  26666.      reported for the pointer.
  26667.  
  26668. identifier
  26669.  
  26670.  
  26671.  
  26672.  
  26673.                      December 18, 1987
  26674.  
  26675.  
  26676.  
  26677.  
  26678.  
  26679.                           - 393 -
  26680.  
  26681.  
  26682.      Each resource has an ``identifier'', a unique value
  26683.      associated with it that clients use to name the
  26684.      resource. An identifier can be used over any connection
  26685.      to name the resource.
  26686.  
  26687. inferiors
  26688.  
  26689.      The ``inferiors'' of a window are all of the subwindows
  26690.      nested below it:  the children, the children's chil-
  26691.      dren, etc.
  26692.  
  26693. input focus
  26694.  
  26695.      The ``input focus'' is where keyboard input goes.  Key-
  26696.      board events are by default sent to the client express-
  26697.      ing interest on the window the pointer is in. This is
  26698.      said to be a ``real estate driven'' input focus. It is
  26699.      also possible to attach the keyboard input to a
  26700.      specific window. Events will then be sent to the
  26701.      appropriate client independent of the pointer position.
  26702.  
  26703. input manager
  26704.  
  26705.      Control over keyboard input is typically provided by an
  26706.      ``input manager'' client, usually part of a window
  26707.      manager.
  26708.  
  26709. InputOnly window
  26710.  
  26711.      A window that cannot be used for graphics requests.
  26712.      InputOnly windows are ``invisible'' and can be used to
  26713.      control such things as cursors, input event generation,
  26714.      and grabbing.  InputOnly windows cannot have InputOut-
  26715.      put windows as inferiors.
  26716.  
  26717. InputOutput window
  26718.  
  26719.      The ``normal'' kind of window that is used for both
  26720.      input and output.  It usually has a background.  Inpu-
  26721.      tOutput windows can have both InputOutput and InputOnly
  26722.      windows as inferiors.
  26723.  
  26724. key grabbing
  26725.  
  26726.      Keys on the keyboard may be passively ``grabbed'' by a
  26727.      client. When the key is pressed, the keyboard is then
  26728.      actively grabbed by the client.
  26729.  
  26730. keyboard grabbing
  26731.  
  26732.      A client can actively ``grab'' control of the keyboard,
  26733.      and key events will be sent to that client rather than
  26734.      the client the events would normally have been sent to.
  26735.  
  26736.  
  26737.  
  26738.  
  26739.                      December 18, 1987
  26740.  
  26741.  
  26742.  
  26743.  
  26744.  
  26745.                           - 394 -
  26746.  
  26747.  
  26748. keysym
  26749.  
  26750.      An encoding of a symbol on a keycap on a keyboard.
  26751.  
  26752. mapped
  26753.  
  26754.      A window is said to be ``mapped'' if a map call has
  26755.      been performed on it.  Unmapped windows and their infe-
  26756.      riors are never viewable or visible.
  26757.  
  26758. modifier keys
  26759.  
  26760.      Shift, Control, Meta, Super, Hyper, ALT, Compose,
  26761.      Apple, CapsLock, ShiftLock, and similar keys are called
  26762.      ``modifier'' keys.
  26763.  
  26764. monochrome
  26765.  
  26766.      A special case of static gray, in which there are only
  26767.      two color map entries.
  26768.  
  26769. obscure
  26770.  
  26771.      A window is ``obscured'' if some other window
  26772.      ``obscures'' it.  A window can be partially obscured
  26773.      and still have visible regions.
  26774.  
  26775. obscures
  26776.  
  26777.      Window A ``obscures'' window B if both are viewable
  26778.      InputOutput windows, if A is higher in the global
  26779.      stacking order, and if the rectangle defined by the
  26780.      outside edges of A intersects the rectangle defined by
  26781.      the outside edges of B.  Note the (fine) distinction
  26782.      with ``occludes''.  Also note that window borders are
  26783.      included in the calculation.
  26784.  
  26785. occlude
  26786.  
  26787.      A window is ``occluded'' if some other window
  26788.      ``occludes'' it.
  26789.  
  26790. occludes
  26791.  
  26792.      Window A ``occludes'' window B if both are mapped, if A
  26793.      is higher in the global stacking order, and if the rec-
  26794.      tangle defined by the outside edges of A intersects the
  26795.      rectangle defined by the outside edges of B. Note the
  26796.      (fine) distinction with "obscures".  Also note that
  26797.      window borders are included in the calculation.  Note
  26798.      that InputOnly windows never obscure other windows but
  26799.      can occludes other windows.
  26800.  
  26801. padding
  26802.  
  26803.  
  26804.  
  26805.                      December 18, 1987
  26806.  
  26807.  
  26808.  
  26809.  
  26810.  
  26811.                           - 395 -
  26812.  
  26813.  
  26814.      Some padding bytes are inserted in the data stream to
  26815.      maintain alignment of the protocol requests on natural
  26816.      boundaries. This increases ease of portability to some
  26817.      machine architectures.
  26818.  
  26819. parent window
  26820.  
  26821.      If C is a child of P, then P is the ``parent'' of C.
  26822.  
  26823. passive grab
  26824.  
  26825.      Grabbing a key or button is a ``passive'' grab. The
  26826.      grab activates when the key or button is actually
  26827.      pressed.
  26828.  
  26829. pixel value
  26830.  
  26831.      A ``pixel'' is an N-bit value (at a single point),
  26832.      where N is the number of bit planes (that is, the depth
  26833.      of) used in a particular window or pixmap. A pixel in a
  26834.      window indexes a color map to derive an actual color to
  26835.      be displayed.
  26836.  
  26837. pixmap
  26838.  
  26839.      A ``pixmap'' is a three dimensional array of bits. A
  26840.      pixmap is normally thought of as a two dimensional
  26841.      array of pixels, where each pixel can be a value from 0
  26842.      to (2^N)-1, where N is the depth (z axis) of the pix-
  26843.      map. A pixmap can also be thought of as a stack of N
  26844.      bitmaps.  A pixmap can only be used on the screen that
  26845.      it was created in.
  26846.  
  26847. plane
  26848.  
  26849.      When a pixmap or window is thought of as a stack of
  26850.      bitmaps, each bitmap is called a ``plane'' or ``bit
  26851.      plane''.
  26852.  
  26853. plane mask
  26854.  
  26855.      Graphics operations can be restricted to only affect a
  26856.      subset of bit planes of a destination. A ``plane mask''
  26857.      is a bit mask describing which planes are to be modi-
  26858.      fied, and is stored in a graphics context.
  26859.  
  26860. pointer
  26861.  
  26862.      The ``pointer'' is the pointing device currently
  26863.      attached to the cursor, and tracked on the screens.
  26864.  
  26865. pointer grabbing
  26866.  
  26867.  
  26868.  
  26869.  
  26870.  
  26871.                      December 18, 1987
  26872.  
  26873.  
  26874.  
  26875.  
  26876.  
  26877.                           - 396 -
  26878.  
  26879.  
  26880.      A client can actively ``grab'' control of the pointer,
  26881.      and button and motion events will be sent to that
  26882.      client rather than the client the events would normally
  26883.      have been sent to.
  26884.  
  26885. pointing device
  26886.  
  26887.      A ``pointing device'' is typically a mouse or tablet,
  26888.      or some other device with effective dimensional motion.
  26889.      Only one visible cursor is defined by the core proto-
  26890.      col, and it tracks whatever pointing device is attached
  26891.      as the pointer.
  26892.  
  26893. property
  26894.  
  26895.      Windows may have associated ``properties'', consisting
  26896.      of a name, a type, a data format, and some data. The
  26897.      protocol places no interpretation on properties. They
  26898.      are intended as a general-purpose naming mechanism for
  26899.      clients. For example, clients might share information
  26900.      such as resize hints, program names, and icon formats
  26901.      with a window manager via properties.
  26902.  
  26903. property list
  26904.  
  26905.      The ``property list'' of a window is the list of pro-
  26906.      perties that have been defined for the window.
  26907.  
  26908. pseudo color
  26909.  
  26910.      A class of color map in which a pixel value indexes the
  26911.      color map entry to produce independent red, green, and
  26912.      blue values.  That is, the color map is viewed as an
  26913.      array of triples (RGB values).  The RGB values can be
  26914.      changed dynamically.
  26915.  
  26916. raise
  26917.  
  26918.      Changing the stacking order of a window so as to
  26919.      occlude another window is to ``raise'' that window.
  26920.  
  26921. rectangle
  26922.  
  26923.      A ``rectangle'' specified by [x,y,w,h] has an (infin-
  26924.      itely thin) outline path with corners at [x,y],
  26925.      [x+w,y], [x+w,y+h] and [x, y+h].  When a rectangle is
  26926.      filled, the lower right edges are not drawn.  For exam-
  26927.      ple, if w=h=0, nothing would be drawn.  For w=h=1, a
  26928.      single pixel would be drawn.
  26929.  
  26930. redirect control
  26931.  
  26932.  
  26933.  
  26934.  
  26935.  
  26936.  
  26937.                      December 18, 1987
  26938.  
  26939.  
  26940.  
  26941.  
  26942.  
  26943.                           - 397 -
  26944.  
  26945.  
  26946.      Window managers (or client programs) may wish to
  26947.      enforce window layout policy in various ways. When a
  26948.      client attempts to change the size or position of a
  26949.      window, the operation may be ``redirected'' to a speci-
  26950.      fied client, rather than the operation actually being
  26951.      performed.
  26952.  
  26953. reply
  26954.  
  26955.      Information requested by a client program by means of
  26956.      the X protocol is sent back to the client with a
  26957.      ``reply.''  Both events and replys are multipexed on
  26958.      the same connection. Most requests do not generate
  26959.      replies.  Some requests generate multiple replies.
  26960.  
  26961. request
  26962.  
  26963.      A command to the server is called a ``request''. It is
  26964.      a single block of data sent over a connection.
  26965.  
  26966. resource
  26967.  
  26968.      Windows, pixmaps, cursors, fonts, graphics contexts,
  26969.      and color maps are known as ``resources''. They all
  26970.      have unique identifiers associated with them for naming
  26971.      purposes. The lifetime of a resource is bounded by the
  26972.      lifetime of the connection over which the resource was
  26973.      created.
  26974.  
  26975. RGB values
  26976.  
  26977.      ``Red, green, and blue'' intensity values are used to
  26978.      define a color.  These values are always represented as
  26979.      16 bit unsigned numbers, with zero the minimum inten-
  26980.      sity and 65535 the maximum intensity.  The X server
  26981.      scales these values to match the display hardware.
  26982.  
  26983. root
  26984.  
  26985.      The ``root'' of a pixmap or gcontext is the same as the
  26986.      root of whatever drawable was used when the pixmap or
  26987.      gcontext was created. The ``root'' of a window is the
  26988.      root window under which the window was created.
  26989.  
  26990. root window
  26991.  
  26992.      Each screen has a ``root window'' covering it. It can-
  26993.      not be reconfigured or unmapped, but otherwise acts as
  26994.      a full fledged window.  A root window has no parent.
  26995.  
  26996. save set
  26997.  
  26998.  
  26999.  
  27000.  
  27001.  
  27002.  
  27003.                      December 18, 1987
  27004.  
  27005.  
  27006.  
  27007.  
  27008.  
  27009.                           - 398 -
  27010.  
  27011.  
  27012.      The ``save set'' of a client is a list of other
  27013.      client's windows which, if they are inferiors of one of
  27014.      the client's windows at connection close, should not be
  27015.      destroyed, and which should be remapped if it is
  27016.      unmapped. Save sets are typically used by window
  27017.      managers to avoid lost windows if the manager should
  27018.      terminate abnormally.
  27019.  
  27020. scanline
  27021.  
  27022.      A ``scanline'' is a list of pixel or bit values viewed
  27023.      as a horizontal row (all values having the same y coor-
  27024.      dinate) of an image, with the values ordered by
  27025.      increasing x coordinate.
  27026.  
  27027. scanline order
  27028.  
  27029.      An image represented in ``scanline order'' contains
  27030.      scanlines ordered by increasing y coordinate.
  27031.  
  27032. screen
  27033.  
  27034.      A server may provide several independent ``screens'',
  27035.      which typically have physically independent monitors.
  27036.      This would be the expected configuration when there is
  27037.      only a single keyboard and pointer shared among the
  27038.      screens.  A Screen structure contains the information
  27039.      about that screen and is linked to the Dislay struc-
  27040.      ture.
  27041.  
  27042. selection 
  27043.  
  27044.      A ``selection'' can be thought of as an indirect pro-
  27045.      perty with dynamic type.  That is, rather than having
  27046.      the property stored in the X server, it is maintained
  27047.      by some client (the "owner").  A selection is global in
  27048.      nature, being thought of as belonging to the user (but
  27049.      maintained by clients), rather than being private to a
  27050.      particular window subhierarchy or a particular set of
  27051.      clients.  When a client asks for the contents of a
  27052.      selection, it specifies a selection ``target type''.
  27053.      This target type can be used to control the transmitted
  27054.      representation of the contents.  For example, if the
  27055.      selection is ``the last thing the user clicked on'',
  27056.      and that is currently an image, then the target type
  27057.      might specify whether the contents of the image should
  27058.      be sent in XYFormat or ZFormat.
  27059.  
  27060.      The target type can also be used to control the class
  27061.      of contents transmitted, for example, asking for the
  27062.      ``looks'' (fonts, line spacing, indentation, and so
  27063.      forth) of a paragraph selection, rather than the text
  27064.      of the paragraph.  The target type can also be used for
  27065.      other purposes.  The semantics are not constrained by
  27066.  
  27067.  
  27068.  
  27069.                      December 18, 1987
  27070.  
  27071.  
  27072.  
  27073.  
  27074.  
  27075.                           - 399 -
  27076.  
  27077.  
  27078.      the protocol.
  27079.  
  27080. server
  27081.  
  27082.      The ``server'', also referred to as the``X server'',
  27083.      provides the basic windowing mechanism. It handles IPC
  27084.      connections from clients, demultipexes graphics
  27085.      requests onto the screens, and multiplexes input back
  27086.      to the appropriate clients.
  27087.  
  27088. server grabbing
  27089.  
  27090.      The server can be ``grabbed'' by a single client for
  27091.      exclusive use. This prevents processing of any requests
  27092.      from other client connections until the grab is com-
  27093.      plete. This is typically only a transient state for
  27094.      such things as rubber-banding and pop-up menus, or to
  27095.      execute requests indivisibly.
  27096.  
  27097. sibling
  27098.  
  27099.      Children of the same parent window are known as
  27100.      ``sibling'' windows.
  27101.  
  27102. stacking order
  27103.  
  27104.      Sibling windows may ``stack'' on top of each other.
  27105.      Windows above both obscure and occlude lower windows.
  27106.      This is similar to paper on a desk. The relationship
  27107.      between sibling windows is known as the ``stacking
  27108.      order''.
  27109.  
  27110. static color
  27111.  
  27112.      Static color can be viewed as a degenerate case of
  27113.      pseudo color, in which the RGB values are predefined
  27114.      and read-only.  See pseudo color.
  27115.  
  27116. static gray
  27117.  
  27118.      Static gray can be viewed as a degenerate case of gray
  27119.      scale, in which the gray values are predefined and
  27120.      read-only.  The values are typically (near-)linear
  27121.      increasing ramps.  See gray scale.
  27122.  
  27123. stipple
  27124.  
  27125.      A ``stipple pattern'' is a bitmap that is used to tile
  27126.      a region to serve as an additional clip mask for a fill
  27127.      operation with the foreground color.
  27128.  
  27129. status
  27130.  
  27131.  
  27132.  
  27133.  
  27134.  
  27135.                      December 18, 1987
  27136.  
  27137.  
  27138.  
  27139.  
  27140.  
  27141.                           - 400 -
  27142.  
  27143.  
  27144.      Many Xlib functions return a success status.  If the
  27145.      function does not succeed, however, its arguments ar
  27146.      not disturbed.
  27147.  
  27148. tile
  27149.  
  27150.      A pixmap can be replicated in two dimensions to
  27151.      ``tile'' a region. The pixmap itself is also known as a
  27152.      ``tile''.
  27153.  
  27154. timestamped
  27155.  
  27156.      A time value, expressed in milliseconds, typically
  27157.      since the last server reset.  Timestamp values wrap
  27158.      around (after about 49.7 days).  The server, given its
  27159.      current time is represented by timestamp T, always
  27160.      interprets timestamps from clients by treating half of
  27161.      the timestamp space as being earlier in time than T,
  27162.      and half of the timestamp space as being later in time
  27163.      than T.  One timestamp value, represented by the con-
  27164.      stant CurrentTime is never generated by the server.
  27165.      This value is reserved for use in requests to represent
  27166.      the current server time.
  27167.  
  27168. true color
  27169.  
  27170.      True color can be viewed as a degenerate case of direct
  27171.      color, in which the subfields in the pixel value
  27172.      directly encode the corresponding RGB values.  That is,
  27173.      the color map has predefined read-only RGB values.  The
  27174.      values are typically (near-)linear increasing ramps.
  27175.      See direct color.
  27176.  
  27177. type
  27178.  
  27179.      A type is an arbitrary atom used to identify the
  27180.      interpretation of property data. Types are completely
  27181.      uninterpreted by the server. They are solely for the
  27182.      benefit of clients.  X predefines type atoms for many
  27183.      frequently used types, and clients also can define new
  27184.      types.
  27185.  
  27186. viewable
  27187.  
  27188.      A window is ``viewable'' if it and all of its ancestors
  27189.      are mapped. This does not imply that any portion of the
  27190.      window is actually visible.  Graphics requests can be
  27191.      performed on a window when it is not viewable, but out-
  27192.      put will not be retained unless the server is maintain-
  27193.      ing backing store.
  27194.  
  27195. visible
  27196.  
  27197.  
  27198.  
  27199.  
  27200.  
  27201.                      December 18, 1987
  27202.  
  27203.  
  27204.  
  27205.  
  27206.  
  27207.                           - 401 -
  27208.  
  27209.  
  27210.      A region of a window is ``visible'' if someone looking
  27211.      at the screen can actually ``see'' it:  the window is
  27212.      viewable and the region is not occluded by any other
  27213.      window.
  27214.  
  27215. window gravity
  27216.  
  27217.      When windows are resized, subwindows may be reposi-
  27218.      tioned automatically relative to some position in the
  27219.      window.  This attraction of a subwindow to some part of
  27220.      its parent is known as ``window gravity''.
  27221.  
  27222. window manager
  27223.  
  27224.      Manipulation of windows on the screen, and much of the
  27225.      user interface (policy) is typically provided by a
  27226.      ``window manager'' client.
  27227.  
  27228. XYFormat
  27229.  
  27230.      The data for a pixmap is said to be in ``XYFormat'' if
  27231.      it is organized as a set of bitmaps representing indi-
  27232.      vidual bit planes.
  27233.  
  27234. ZFormat
  27235.  
  27236.      The data for a pixmap is said to be in ``ZFormat'' if
  27237.      it is organized as a set of pixel values in scanline
  27238.      order.
  27239.